39066
建议管理员 封此贴 并没有找到源码
- 39066 2016-10-24 已签到连续签到1天,获得了5个金钱
不得不说着简直是个深坑####。
官方文档说明也太差了,菜鸟级别的怎么知道是console.php 配置去加。
都会在main.php 去加 然后总是失败。很多人都遇到上面的问题:Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'
其实这里只是你的
'authManager' => ['class' => 'yii\rbac\DbManager', ],
配置放错位置了。深入源码你可以知道其实这里他找的配置文件是config/console.php里面的components组建。
在里面加入:
'authManager' => ['class' => 'yii\rbac\DbManager', ],
就ok了
$config = [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'db' => $db, ], 'params' => $params, /* 'controllerMap' => [ 'fixture' => [ // Fixture generation command line. 'class' => 'yii\faker\FixtureController', ], ], */ ];
兄弟 我纠结了一下午的问题 终于被你的说明 茅塞顿开 。。
简单的问题 考虑的 哎 一言难尽 感谢感谢- 39066 赞了回答
很多人都遇到上面的问题:Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'
其实这里只是你的
'authManager' => ['class' => 'yii\rbac\DbManager', ],
配置放错位置了。深入源码你可以知道其实这里他找的配置文件是config/console.php里面的components组建。
在里面加入:
'authManager' => ['class' => 'yii\rbac\DbManager', ],
就ok了
$config = [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], 'log' => [ 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'db' => $db, ], 'params' => $params, /* 'controllerMap' => [ 'fixture' => [ // Fixture generation command line. 'class' => 'yii\faker\FixtureController', ], ], */ ];