无法安装yii2高级模板,迁移命令
Can't install yii2 advanced template, migrate command
安装yii2 advanced template时遇到的"migrate"冲突问题。
创建数据库后,我尝试 运行 yii migrate 但收到此异常:
'yii\base\InvalidCallException' 消息 'Setting read-only property: yii\console\Application::db'
我不知道为什么会这样,因为配置没问题,我可以通过 shell 或 dBeaver 使用数据库。 OS Linux 薄荷。感谢您的帮助。
控制台命令“/usr/bin/php /var/www/html/advanced/yii 迁移”。
console/config/main-local.php:
return [
'bootstrap' => ['gii'],
'modules' => [
'gii' => 'yii\gii\Module',
],
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => 'pw',
'charset' => 'utf8',
],
];
确保您设置正确 console/config/main.php(或 main-local.php)
在组件部分 .. 数据库条目
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'components' => [
.....
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=your_db_name',
'username' => 'your_username',
'password' => 'your_pwd',
'charset' => 'utf8',
],
安装yii2 advanced template时遇到的"migrate"冲突问题。 创建数据库后,我尝试 运行 yii migrate 但收到此异常:
'yii\base\InvalidCallException' 消息 'Setting read-only property: yii\console\Application::db'
我不知道为什么会这样,因为配置没问题,我可以通过 shell 或 dBeaver 使用数据库。 OS Linux 薄荷。感谢您的帮助。
控制台命令“/usr/bin/php /var/www/html/advanced/yii 迁移”。
console/config/main-local.php:
return [
'bootstrap' => ['gii'],
'modules' => [
'gii' => 'yii\gii\Module',
],
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => 'pw',
'charset' => 'utf8',
],
];
确保您设置正确 console/config/main.php(或 main-local.php)
在组件部分 .. 数据库条目
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'components' => [
.....
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=your_db_name',
'username' => 'your_username',
'password' => 'your_pwd',
'charset' => 'utf8',
],