My Rbac Authorization Upgrade.

Hey community,

Today i did a composer upgrade from yii2 alpha to yii2 beta, and after read upgrade notes i resolve all my php errors.

But now i have a problema with my authorization system, i am currently using RBAC and my rbac.php file look’s like this:


use yii\rbac\Item;

$biz_rule_post_owner_id = 'return Yii::$app->user->identity->id==Yii::$app->request->post("id") || Yii::$app->user->identity->id==Yii::$app->request->get("id");';

return [

    'test.index' => ['type' => Item::TYPE_OPERATION, 'description' => 'test index operation', 'bizRule' => NULL, 'data' => NULL],

    'testManagement' => [

        'type' => Item::TYPE_TASK,

        'description' => 'test management operations',

        'children' => [



        'bizRule' => NULL,

        'data' => NULL


... etc etc +200 lines.

To check user permissions i use:

		$actionId = $action->id;

		$controllerId = $action->controller->id;





		if (!Yii::$app->user->can("$controllerId.$actionId"))


I saw that rbac thing was changed, and i can’t find clean instructions to upgrade my solucion.

What is the perfect way to upgrade my code ?

Thank you.

don’t use alpha or beta. you should use last dev version. api is changing every week :slight_smile:

I am currently using last version of dev channel.

My problem was solved like this:


namespace app\commands;

use Yii;

use yii\console\Controller;

class RbacController extends Controller


    public function actionInit()


        $auth = new \yii\rbac\PhpManager; --> With this line !!

        $testIndex = $auth->createPermission('testIndex');

        $testIndex->description = 'test index operation';


        $accountIndex = $auth->createPermission('accountIndex');

        $accountIndex->description = 'account index operation';


        $accountView = $auth->createPermission('accountView');

        $accountView->description = 'account view operation';


        ...... etc.