PHP code example of xihrni / yii2-behavior-rbac

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

    

xihrni / yii2-behavior-rbac example snippets


yii migrate --migrationPath=@vendor/xihrni/yii2-behavior-rbac/migrations

interface AdminInterface
{
    public static function getPermissions($id);
}



namespace app\controllers;

use xihrni\yii2\behaviors\RbacBehavior;

class IndexController extends \yii\web\Controller
{
    public function behaviors()
    {
        return array_merge(parent::behaviors(), [
            'rbac' => [
                'class' => RbacBehavior::className(),
                'switchOn' => true,
                'userModel' => 'app\models\Admin',
                'roleModel' => 'app\models\AuthRoleModel',
                'permissionModel' => 'app\models\AuthPermissionModel',
                'assignmentModel' => 'app\models\AuthAssignmentModel',
            ],
        ]);
    }
}