正如here所述,我正在尝试进行迁移,以便让yii创建用户身份验证表。但是我得到了错误:
Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'
authManager存在于配置中,但仍然出现该错误。组态:
'components' => [
...
'db' => $db,
'authManager' => [
'class' => 'yii\rbac\DbManager',
// 'defaultRoles' => ['guest'],
],
...
],
有什么问题?
最佳答案
问题非常简单:未使用配置。 yii migrate
是一个控制台命令,通常这些命令的配置位于单独的文件中。
如果是基于 yii2-app的模板(从中创建了我的应用程序),则存在一个config/console.php
配置文件,需要在其中声明authManager。仅在声明的config/web.php
中添加它是不够的。
如果使用 yii2-app-高级,则authManager应该在console/config/main.php
中声明,而不在后端或前端配置文件中声明。
关于configuration - Yii2:无法执行RBAC迁移(您应该配置 “authManager”…),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30478903/