PHP code example of yiichina / yii2-rbac-module

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

    

yiichina / yii2-rbac-module example snippets


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

/index.php?r=rbac/assignment
/index.php?r=rbac/permission
/index.php?r=rbac/role
/index.php?r=rbac/rule

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
            'only' => ['delete'],
            'rules' => [
                'actions' => ['delete'],
                'allow' => true,
                'roles' => ['admin'], // 在这里指定可以操作此动作的角色
                'verbs' => ['POST'],
            ],
        ],
    ];
}