Building Authorization Data with console command in RBAC PhpManager failed

I have configured authmanager in config/web as

'authManager' => [

		    'class' => 'yii\rbac\PhpManager', // THIS IS YOUR AUTH MANAGER



Created rbac folder along with Item.php,Assignment.php,Rule.php with full read, write permission

In the Commands folder created the controller RbacController.php


namespace app\commands;

use Yii;

use yii\console\Controller;

class RbacController extends Controller


    public function actionInit()


        $auth = \yii::$app->authManager;


        // add "createPost" permission

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

        $createPost->description = 'Create a post';


        // add "updatePost" permission

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

        $updatePost->description = 'Update post';


        // add "author" role and give this role the "createPost" permission

        $author = $auth->createRole('author');


        $auth->addChild($author, $createPost);

        // add "admin" role and give this role the "updatePost" permission

        // as well as the permissions of the "author" role

        $admin = $auth->createRole('admin');


        $auth->addChild($admin, $updatePost);

        $auth->addChild($admin, $author);

        // Assign roles to users. 1 and 2 are IDs returned by IdentityInterface::getId()

        // usually implemented in your User model.

        $auth->assign($author, 2);

        $auth->assign($admin, 1);



When i execute the command i am getting following error

E:\projects\yii2>yii.bat rbac/init

PHP Fatal Error 'yii\base\ErrorException' with message 'Call to a member functio

n createPermission() on a non-object'

in E:\projects\yii2\commands\RbacController.php:15

Stack trace:

#0 [internal function]: yii\base\ErrorHandler->handleFatalError()

#1 {main}