Building Backend

Hello all!

I want to build a backend for my application and I want to make it a module. For example i open h__p://localhost/myapp/index.php?r=admin and that runs the admin module. Then if I open .../index.php?r=admin/something this would search for SomethingController in admin module. I want to change it. If this controller is not found I want it to run AdminController from module ‘something’. How can I manage that?

The idea is that every module in my application will have AdminController.php which would be accessable through my admin module.

As far as I understand, you want to redirect to a controller, if the controller being accessed doesn’t exists?

Inside your module you have a function called beforeControllerAction, use this:

public function beforeControllerAction($controller, $action)


 if (parent::beforeControllerAction($controller, $action)) {

  $route = $controller.'/'.$action;

  if ($route !== 'something/someaction')




It seems that you want HMVC. Yii is not built for that.

Please check these links as a guide to build your admin backend:

Also, for access control, I suggest Rights.