Admin section

I have learned to create a separate module named “admin” to hold controllers and views for Admin section accessible via I’m keeping all my models in protected/models folder for now. However i’m trying to figure out how to create separate modules still keeping the admin controllers and views within the modules themselves.

Let me explain

List of Modules in my app:

  1. cms

  2. user

  3. store

  4. admin (i’m confused if this has to be there?)



  • protected/modules/cms/controllers/node.php

  • protected/modules/store/controllers/product.php

Above are two controllers from two different modules.



Now if i generate "admin section controllers and views" from Gii for the above 2 controllers, they both go in admin module and get mixed up so the modularity of these modules is washed away. I want the "CMS" module complete in itself i.e. the admin section controllers and views are self-contained within the "CMS" modules directory and not in the separte "admin" module.

I’m learning Yii and a proper guide would be highly appreciated.



You can create admin controllers in each module. If it cannot be done with gii out of the box, just copy the files or copy paste. Personally, I just use the default controller with different layout/theme for the admin views.

I think almost all mid to large size sites would need a separate admin section and there should be a defacto method in Yii to support this and not the way arounds. In cakephp, there’s something called “admin routing” in which you simply name your controller methods as admin_create, admin_delete in same controller and they’re magically available as or

I’m also looking at this post by Qiang:

Thanks for you suggestion, i’ll test and try a few things although i would love to see this thing covered (out of box) in a basic generated application using yiic.

Appreciate your commments.