You know, I can do it in CakePHP just creating a DefaulController or something like that in app root. I can extend it to all my app controllers with no problem.
it can be done easily in Yii also. just create your MainController.php inside components directory
class MainController extends CController
{
public function init()
{
parent::init();
// add your code for init here
}
}
and inside your controllers you can simply extend MainController
class SiteController extends MainController
{
// class contents
}
you can also configure Yii so you can put your MainController.php inside the dir protected/controllers and then extending it with classes in the same dir by modifying your protected/config/main.php files as follows
.................
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.controllers.*', // added so class will be autoloaded from protected/controllers
),
.................
what i did there was add this line
'application.controllers.*',
to what was generated in the config file by default.