Download the PHP package futuretek/yii2-rbac without Composer
On this page you can find all versions of the php package futuretek/yii2-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download futuretek/yii2-rbac
More information about futuretek/yii2-rbac
Files in futuretek/yii2-rbac
Package yii2-rbac
Short Description RBAC
License Apache-2.0
Homepage https://www.futuretek.cz/
Informations about the package yii2-rbac
RBAC
Requirements
- For RBAC to function correctly Yii cache component must be configured.
Configuration
Place config into @app/rbac/config.php
Console actions
- yii rbac/init - Initialize RBAC database, builds permissions and default roles.
- yii rbac/export - Export permissions to file.
- yii rbac/import - Import permissions from file based on application language.
Usage
Permissions Init
ATTENTION This command should be used only in development process.
Permission names are created from controller and action name.
Init command will create permissions and roles. Also admin user is created and granted all permissions.
When in developer mode, this command enables you to clear original permissions. In other environments only permission update is possible.
Permissions Export
Permissions should be exported and committed to versioning system when releasing the application.
Export is done using the command:
These files are created in @app/rbac/
during export:
auth-assignment
auth-item
auth-item-child
auth-rule
Permissions Import
Permission import should be executed when new release is deployed on target instance. Import will restore exported permissions from files to database.
Import is done using command:
Import expect that files noted above are present in @app/rbac/
Note: file auth-item
should be renamed to current language to import to work properly - see next chapter.
Permission translation
Authentication items (permission and role names) contained in file auth-item
can/should be translated.
When importing permissions, the script is looking for file corresponding to selected
language (Yii::$app->language
). File format is:
where <iso-code>
is two digit language ISO code. For example auth-item.en
.
If application language is set using locale (eg. en-US), only first part (language code) is used.
Usage in application
For operations with permissions (create, update, delete) use AuthItem
model (instead of Yii:$app->authManager).
Permission checking method has not changed - Yii::$app->user->can()
.
All versions of yii2-rbac with dependencies
futuretek/yii2-shared Version ^3.0.0
futuretek/yii2-yii-shared Version ^2.0.0
futuretek/yii2-migrations Version ^1.5.2