RBAC using database

In case of CDbAuthManager, in which file do we specify the hierarchy?

I understand that the hierarchy is to be mentioned as…

$auth=Yii::app()->authManager;

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

$task=$auth->createTask(‘updateOwnPost’,‘update a post by author himself’,$bizRule);

$task->addChild(‘updatePost’);

$role=$auth->createRole(‘reader’);

$role->addChild(‘readPost’);

But I am at a loss as to which file this piece of code should go into?

Thanks in advance.

At early stages of development, yiic shell can be used to manipulate RBAC data directly. Later, at some point of the process, you may want to integrate an extension designed for it.

You can use some RBAC extensions(for example SRBAC), which will allow you to manage roles/tasks and operations via website. There are some other extensions for this purpose too.

If your project is smaller, you can use use console application with commands you mentioned, to store your auth data into database. This is better approach for smaller projects.