PHP code example of zelenin / yii2-rbac-module

1. Go to this page and download the library: Download zelenin/yii2-rbac-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zelenin / yii2-rbac-module example snippets


'components' => [
    'authManager' => [
        'class' => \Zelenin\yii\modules\Rbac\components\DbManager::className(),
        'itemFile' => '@common/config/rbac/items.php',
        'assignmentFile' => '@common/config/rbac/assignments.php',
        'ruleFile' => '@common/config/rbac/rules.php',
        'defaultRole' => 'user',
		'roleParam' => 'role' // User model attribute
	]
]

'components' => [
    'authManager' => [
        'class' => \Zelenin\yii\modules\Rbac\components\PhpManager::className(),
        'itemFile' => '@common/config/rbac/items.php',
        'assignmentFile' => '@common/config/rbac/assignments.php',
        'ruleFile' => '@common/config/rbac/rules.php',
        'defaultRole' => 'user',
		'roleParam' => 'role', // User model attribute
	]
]

php composer.phar 

php yii migrate --migrationPath=@yii/rbac/migrations/

php yii rbac/generate