PHP code example of xj / yii2-rbac-module

1. Go to this page and download the library: Download xj/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/ */

    

xj / yii2-rbac-module example snippets


'components' => [
    'authManager' => [
        'class' => 'yii\rbac\PhpManager',
        'itemFile' => '@common/rbac/items.php',
        'assignmentFile' => '@common/rbac/assignments.php',
        'ruleFile' => '@common/rbac/rules.php',
    ],
],

'modules' => [
    'rbac' => [
        'class' => 'xj\rbac\Module',
        'userIdField' => 'id',
        'userNameField' => 'username',
        'userTableModelName' => '\common\models\Admin',
        'allowedIPs' => ['127.0.0.1', '::1'],
        'roles' => ['admin'],
    ]
],

'modules' => [
    'rbac' => [
        'class' => 'xj\rbac\Module',
        'userIdField' => 'id',
        'userNameField' => 'username',
        'userTableModelName' => '\common\models\Admin',
        'layout' => 'main', //optional
        'allowedIPs' => ['127.0.0.1', '::1'],
        'roles' => ['@', '?'],
    ]
],

'modules' => [
    'rbac' => [
        'class' => 'xj\rbac\Module',
        'userIdField' => 'id',
        'userNameField' => 'username',
        'userTableModelName' => '\common\models\Admin',
        'allowedIPs' => ['*'],
        'roles' => ['admin'],
    ]
],

http://project/index.php?r=rbac