Using RBAC
Role-Based Access Control (RBAC) provides simple yet powerful centralized access control. It is the most powerful access control method available in Yii. It is described in the guide, but since it is rather complex and powerful, it is not as easy to understand without getting under the hood a little.
In this recipe, we will take the roles hierarchy from the definitive guide, import it, and explain what is happening internally.
Getting ready
- Create a new application by using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
- Create a MySQL database and configure it.
- Configure the
authManager
component in yourconfig/main.php
andconfig/console.php
as follows: ...
Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.