RBAC Manager for Yii 2 ¶
Documentation ¶
Installation ¶
The preferred way to install this extension is through composer.
Either run
php composer.phar require mdmsoft/yii2-admin "*"
for dev-master
php composer.phar require mdmsoft/yii2-admin "dev-master"
or add
"mdmsoft/yii2-admin": "*"
to the require section of your composer.json
file.
Usage ¶
Once the extension is installed, simply modify your application configuration as follows:
return [
'modules' => [
'admin' => [
'class' => 'mdm\admin\Module',
'layout' => 'left-menu', // default to null. other avaliable value 'right-menu' and 'top-menu'
'controllerMap' => [
'assignment' => [
'class' => 'mdm\admin\controllers\AssignmentController',
'userClassName' => 'app\models\User',
'idField' => 'id'
]
],
'menus' => [
'assignment' => [
'label' => 'Grand Access' // change label
],
'route' => null, // disable menu
],
]
...
],
...
'components' => [
....
'authManager' => [
'class' => 'yii\rbac\PhpManager', // or use 'yii\rbac\DbManager'
]
],
'as access' => [
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
'admin/*', // add or remove allowed actions to this list
]
],
];
See Yii RBAC for more detail. You can then access Auth manager through the following URL:
http://localhost/path/to/index.php?r=admin
http://localhost/path/to/index.php?r=admin/route
http://localhost/path/to/index.php?r=admin/permission
http://localhost/path/to/index.php?r=admin/menu
http://localhost/path/to/index.php?r=admin/role
http://localhost/path/to/index.php?r=admin/assignment
To use menu manager (optional). Execute yii migration here:
yii migrate --migrationPath=@mdm/admin/migrations
If You use database (class 'yii\rbac\DbManager') to save rbac data. Execute yii migration here:
yii migrate --migrationPath=@yii/rbac/migrations