Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

1.2.6: Fatal error: Call to a member function setVar() on a non-object in C:\...\IndexController.php

I'm trying to pass a variable to the view, but am getting the following error:

"Fatal error: Call to a member function setVar() on a non-object in C:...\IndexController.php"

class IndexController extends Phalcon\Mvc\View {
    public function indexAction() {
        $this->view->setVar('test', 'this is a test'); // This is the line it's complaining about
    }
}

Removing this line allows the page to load correctly. What is happening here?



28.3k
Accepted
answer
edited Oct '14

you extends View class for controller? Should be

class IndexController extends \Phalcon\Mvc\Controller

Oh duh! That's what it was. Thanks :)