RBAC创建过程中,无法使用migrate进行相关数据表的创建 [ 2.0 版本 ]
yii migrate --migrationPath=@yii/rbac/migrations/
组件的配置
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager',
'itemTable' => 'auth_item',
'assignmentTable' => 'auth_assignment',
'itemChildTable' => 'auth_item_child',
'db' => 'wangmumudb',
],
]
提示的错误
*** applying m140506_102106_rbac_init
Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'
共 10 个回答
-
jhomephper 回答于 2015-06-27 22:50 举报
这个估计是Bug,我也没成功过
-
jhomephper 回答于 2015-06-28 13:01 举报
复制表数据后,不要修改,直接执行sql,之后统一添加表前缀即可
共 1 条回复ZendLaravelYii 回复于 2015-06-29 08:28 回复晓得的呢啊
-
在
console/config/main.php
中添加如下代码:'components' => [ 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], ],
关闭终端,重新打开终端执行
php yii migrate --migrationPath=@yii/rbac/migrations
共 1 条回复huaixiaoya 回复于 2016-03-14 16:02 回复配置放在console/config/main.php 中就可以
放在 backend/config/main.php 中为什么就不行呢?
如果我只想后台运用这个权限,应该怎么配置Zachary_Guo , huaixiaoya 觉得很赞 -
很多人都遇到上面的问题: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', ], ], */ ];
共 1 条回复 -
执行这条命令php yii migrate --migrationPath=@izyue/admin/migrations
报错Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @izyue/admin/migrations' in H:\wamp\www\advanced\vendor\yiisoft\yii2\BaseYii.php:154 Stack trace: #0 H:\wamp\www\advanced\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(117): yii\BaseYii::getAlias('@izyue/admin/mi...') #1 H:\wamp\www\advanced\vendor\yiisoft\yii2\console\controllers\MigrateController.php(168): yii\console\controllers\BaseMigrateController->beforeAction(Object(yii\base\InlineAction)) #2 H:\wamp\www\advanced\vendor\yiisoft\yii2\base\Controller.php(154): yii\console\controllers\MigrateController->beforeAction(Object(yii\base\InlineAction)) #3 H:\wamp\www\advanced\vendor\yiisoft\yii2\console\Controller.php(128): yii\base\Controller->runAction('', Array) #4 H:\wamp\www\advanced\vendor\yiisoft\yii2\base\Module.php(523): yii\console\Controller->runAction('', Array) #5 H:\wamp\www\advanced\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array) #6 H:\wamp\www\advanced\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array) #7 H:\wamp\www\advanced\vendor\yiisoft\yii2\base\Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request)) #8 H:\wamp\www\advanced\yii(27): yii\base\Application->run() #9 {main}
zhoumin 觉得很赞
ZendLaravelYii 浙江杭州
注册时间:2015-06-16
最后登录:2021-01-20
在线时长:21小时52分
最后登录:2021-01-20
在线时长:21小时52分
- 粉丝9
- 金钱1876
- 威望20
- 积分2286