What are modules for ??? confused.

[size="4"]Hi all,

i am bit confused with what modules does in yii ??

i need to develop a back end system which has 3 user levels… (admin, user, superAdmin)

my question is, do we need to have separate controllers ? for each user as AdminController, UserController and SuperAdminController inside the normal Controller folder or…

i will have to create separate folders for each user and direct them to there or i will create modules for each user… i am very confused of how to handle this matter…

i am new to yii and have been working on writing php from the scratch… so normally how i do is, inside the website folder… i will have a admin folder (which is the backend) so when a user logs in i will send him there inside admin’s folder…

so i am confused of how to accomplish that task with yii ? is there any inbuilt way or any extension.

please give your suggestions… bit urgent… thanks[/size]

anyone there to help me

From the definitive Yii Guide:

"A module is a self-contained software unit that consists of models, views, controllers and other supporting components. In many aspects, a module resembles to an application. The main difference is that a module cannot be deployed alone and it must reside inside of an application. Users can access the controllers in a module like they do with normal application controllers."

So for your admin area, yeh you can create a module and then you can access the module like this:


For the users authorization part, read about the Yii’s RBAC, or can also implement a non-RBAC type authorization system.

appreciate this… many thanks…

[size="4"]btw, what you mean as non-RBAC ??[/size]

A non-rbac is an authorization system without RBAC :)

So in other words, you can implement authorization without using the Yii’s rbac structure, for instance, you may have a function like this:

public static function isMember()


  return Yii::app()->user->role === User::MEMBER;


where MEMBER is a constant defined in the User model suppose.

class User {

const MEMBER = 1;





then you can check if the logged in user is a member like this:

if (User::isMember())



  //Not a member

This is a very basic example, you can offcourse put this in a component or maybe extend CWebUser and put it there.

[size="4"]hey thanks again… this is how i am doing it… (without rbac)[/size]


Its depend on your site functionality as you want different controller or single controller for task ( functionality ), you can give access to each action/page by access rules as shown below, its in your controller,

public function accessRules()


		return array(

			array('allow',  // allow all users to perform 'index' and 'view' actions




			array('allow', // allow authenticated user to perform 'create' and 'update' actions




			array('allow', // allow admin user to perform 'admin' and 'delete' actions




			array('deny',  // deny all users





you can define type of user in globally as Yii::app()->user->role and can use them to set different access in controller.


as your functionality you can make admin module and create nested modules inside admin module and you can access them seperately.

so the hierarchy will ?r=admin/customer/customerdetail/admin ( ?r=parentModule/childModule/controller/action )

really thanks :)