vova07 / yii2-start-rbac-module
The RBAC module for Yii2-Start application.
Installs: 9 875
Dependents: 2
Suggesters: 0
Security: 0
Stars: 12
Watchers: 5
Forks: 6
Open Issues: 2
Type:yii2-extension
Requires
This package is not auto-updated.
Last update: 2024-10-26 16:20:46 UTC
README
Yii2 RBAC module.
This module provide an RBAC managing system for your yii2 application.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist vova07/yii2-start-rbac-module "*"
or add
"vova07/yii2-start-rbac-module": "*"
to the require section of your composer.json
file.
Configuration
Edit authManager
component in your application config file:
'authManager' => [ 'class' => 'yii\rbac\PhpManager', 'defaultRoles' => [ 'user' ], 'itemFile' => '@vova07/rbac/data/items.php', 'assignmentFile' => '@vova07/rbac/data/assignments.php', 'ruleFile' => '@vova07/rbac/data/rules.php', ]
Add new filed role
to your users
table.
Usage
Once the extension is installed, simply use it in your code by:
Yii::$app->user->can('admin');
Info
By default RBAC
module provide 3 defaults roles: user
, admin
and superadmin
.
You can add more roles by creating your own rules.php
file.
If you want to regenerate the rbac
files, you can change the itemFile
, assignmentFile
and ruleFile
in your config authManager
section and run php yii cron/cron/init
.