23

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?

1 Answer 1

66

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Then why official doc said this : In case of yii2-advanced-app the authManager should be declared only once in common/config/main.php.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.