We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

hook

On some other frameworks i can describe hook and with that , before everypage run,this hook running ( this hook is controller like anyother page but its working before every page)

Is there anything like that ?



39.3k

Thanks for ur response but i already know initialize. I dont want to write my code every controller , i will create a controller and it will run before every controller

(i.e : https://ellislab.com/codeigniter%20/user-guide/general/hooks.html)

you can implement a base controller, write the initialize in that ,and other controller extends from this base controller

class BaseController extends \Phalcon\Mvc\Controller{
    public function initialize()
    {
        # your hook code here;
    }

}

and other controller like this

class OtherController extends BaseController{

}

hope it can help you



39.3k

Thanks NitronPlus , it will help me