Parent Controller For All Frontend Controller

Hello Guys,

I am learning the Yii 2.0 and I would like to have a common class/Controller which init method should be called before going for specific controller action.

In yii 1.1, I am adding a Controller.php in Components and it was extended by all other Controller.

Can you please guide me on this.

Many Thanks,


I really need to find option for this to migrate from Yii 1.1 to 2.0. Any help would be appreciated.

Many Thanks in advance.

In Yii 2 you can do the same. Extend it explicitly with its namespace.

I have created the same class but I cant find how to auto import the frontend/components/MyController.php class?

Can you help me with the syntax and where to place it?

Many thanks.

use frontend\components\MyController;

, just above the definition of any class that use it.

You may check PHP namespace features and existing Yii 2 example code (official yii2* extensions and templates), so long as namespaces are everywhere today.