Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2: Cannot perform RBAC migration (You should configure "authManager"...)

Tags:

As it is described here I'm trying to do the migration in order to let yii create the user authentication tables. However I get the error:

Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'

The authManager is present in the configuration but I still get that error. Configuration:

'components' => [     ...     'db' => $db,     'authManager'  => [         'class'        => 'yii\rbac\DbManager',         //            'defaultRoles' => ['guest'],     ],     ... ], 

What's the problem?

like image 593
robsch Avatar asked May 27 '15 09:05

robsch


1 Answers

Problem was quite simple: The configuration was not used. yii migrate is a console command and usually the configuration for such commands is placed in a seperated file.

In case of yii2-app-base template, from which I have created my application, there is a config/console.php configuration file where the authManager needs to be declared. It is not sufficient to have it in the config/web.php declared only.

In case of yii2-app-advanced the authManager should be declared in console/config/main.php and not in the backend or frontend configuration files.

like image 159
robsch Avatar answered Oct 05 '22 23:10

robsch