Use yii's RBAC

I am trying to use yii’s RBAC. Therefor I am following this document here.

I set up the following in the main config file:




The auth.php is writable but empty in the data folder.

I am trying to run this code without success:



$auth->createOperation('createPost','create a post');

$auth->createOperation('readPost','read a post');

$auth->createOperation('updatePost','update a post');

$auth->createOperation('deletePost','delete a post');























I am getting this error message - presumably because my auth.php file empty?!

Invalid argument supplied for foreach()

Do I need to create roles within the auth.php file as well? It sounded like I can use $role=$auth->createRole(‘author’); instead?

Maybe I am on a completely wrong track here…



at the end…


I am having the similar problem where i am using CBDAuthManager

In config/main.php




		'defaultRoles'=>array('authenticated','guest', 'admin'), //authenticated=logged in user & admin=user name is equal to admin


I am trying to run this code without success:


$bizRule=‘return !Yii::app()->user->isGuest;’;

$auth->createRole(‘authenticated’, ‘authenticated user’, $bizRule);

$bizRule=‘return Yii::app()->user->isGuest;’;

$auth->createRole(‘guest’, ‘guest user’, $bizRule);

$bizRule=‘return Yii::app()->user->name === “admin”;’;

$role = $auth->createRole(‘admin’, ‘administrator’);

$auth->assign(‘admin’,1); // adding admin to first user created

$bizRule = ‘return Yii::app()->user->id==$params[“User”]->id;’;

$auth->createTask(‘updateSelf’, ‘update own information’, $bizRule);

$role = $auth->getAuthItem(‘authenticated’); // pull up the authenticated role

$role->addChild(‘updateSelf’); // assign updateSelf tasks to authenticated users


Firstly i am not sure where to put this file and how to execute. Your help would be great.

Solved: pl check

is it possible somebody tell me how could i put access for my auth.php for apache?