iiYii / getyii

Yii2 community 请访问
http://www.getyii.com/
Other
440 stars 163 forks source link

本地安装生成测试数据报错 #182

Closed huacaizhi closed 3 years ago

huacaizhi commented 3 years ago

生成测试数据报错提示: *** applying m190908_055507_init_data 是否生成测试问题数据? (yes|no) [yes]: [> ] 0% (0/100) ETA: n/a > execute SQL: INSERT INTO {{%merit_template}} (id, type, title, unique_id, method, event, action_type, rule_key, rule_value, increment, status, created_at, updated_at) VALUES (1, 1, '登录', 'site/login', 2, 0, 2, 1, 1, 2, 1, 1458657160, 1458823425), (2, 1, '发帖', 'topic/default/create', 2, 0, 2, 0, NULL, 6, 1, 1458657218, 1458657218), (3, 1, '回复', 'topic/comment/create', 2, 0, 2, 0, NULL, 4, 1, 1458657251, 1458657251), (4, 1, '发动弹', 'tweet/default/create', 2, 0, 2, 0, NULL, 4, 1, 1458657296, 1468647701); ... done (time: 0.001s) Exception 'yii\base\InvalidConfigException' with message 'Please configure UrlManager::hostInfo correctly as you are running a console application.'

forecho commented 3 years ago

试试 https://forum.yiiframework.com/t/create-url-in-console-applications/71792

https://github.com/yiisoft/yii2/issues/2944#issuecomment-39192548

huacaizhi commented 3 years ago

@forecho 谢谢,解决了。 console/config/main.php 的 components 数组下增加

urlManager' => [
            'class' => \yii\web\UrlManager::class,
            'hostInfo' => 'http://www.example.com',
]