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.

Call to undefined method Phalcon\Mvc\Controller::initialize() in.....

ControllerBase.php

<?php

namespace Baby\Home\Controllers;

use Phalcon\Mvc\Controller;

class ControllerBase extends Controller
{

    public function initialize() {
        parent::initialize();
    }
}


8.5k

The latest version

Hi,

The initialize methode exists in Controller: http://docs.phalconphp.com/en/latest/reference/controllers.html#initializing-controllers

This works well for me:

  • BaseController.php
<?php

use \Phalcon\Tag;

class BaseController extends \Phalcon\Mvc\Controller
{
    public function initialize()
    {

        $this->tag->prependTitle('Test | ');
    }
}
  • IndexController.php
<?php

use Models,
    \Phalcon\Tag;

class IndexController extends BaseController
{

    public function initialize()
    {
        $this->tag->setTitle('Home');
        parent::initialize();
    }

    public function indexAction()
    {
        // ...
    }
}