We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

How to access a function within a model

I need to access a funcion set in ControllerBase within a model :

use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;

class ControllerBase extends Controller
    public function getAnswer()
        return '42';

use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Relation;
class SomeModel extends Model
    public function initialize()
        // i need the answer here !!

edited Mar '14

Hi, two ways

$function = new ControllerBase();


workd like a charm, thank you :)