php yii2 安装 - 迁移命令不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24531583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:21:09  来源:igfitidea点击:

yii2 installation - migrate command not working

phpinstallationyii2

提问by Yatin Mistry

I am trying to install yii2 in ubuntu.

我正在尝试在 ubuntu 中安装 yii2。

yii2 migrate command not working

yii2 迁移命令不起作用

yii migrate

I am getting Below error

我收到以下错误

php yii /var/www/event-tracking/migrate
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
Could not open input file: yii

回答by user3797931

After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.

安装应用程序后,您必须执行以下步骤来初始化已安装的应用程序。您只需要一劳永逸地执行这些操作。

Execute the initcommand and select dev as environment.

执行init命令并选择 dev 作为环境。

php /path/to/yii-application/init

Create a new database and adjust the components.db configuration in common/config/main-local.phpaccordingly.

创建一个新数据库并相应地调整 components.db 配置common/config/main-local.php

Apply migrations with console command:

使用控制台命令应用迁移:

yii migrate

yii migrate

or for windows:

或对于窗户:

php yii migrate

This command should create the table User,and Migration in your database

此命令应在您的数据库中创建表 User 和 Migration

ref[Yii2 Documentation]

参考[Yii2 文档]

回答by Dylan Hildenbrand

If yii migrateisn't working, you can also try php yii migrateas the yii command is just a PHP file that needs to be run.

如果yii migrate不起作用,您也可以尝试,php yii migrate因为 yii 命令只是一个需要运行的 PHP 文件。

回答by Rostyslav Pylypenko

This could happen if You clone the project from the git repo. "yii" is added to .gitignore. Follow the instruction described in yii2 installation - migrate command not workingIf You'are lazy of afraid to do it for some reasons, just copy "yii" file and /config/*-local.php files into Your project directory.

如果您从 git 存储库克隆项目,则可能会发生这种情况。“yii”被添加到 .gitignore。按照yii2 安装中描述的说明- migrate 命令不起作用如果您因为某些原因而害怕这样做,只需将“yii”文件和 /config/*-local.php 文件复制到您的项目目录中。

回答by Temur ochilov

you can use php yii2 migrate

你可以使用 php yii2 migrate

this worked for me

这对我有用

回答by shekhar

For init use following command on windows

对于 init 在 Windows 上使用以下命令

c:\php /path of your yii application/init

c:\php /path of your yii application/init

For migration:

对于迁移:

c:\php (path of your yii file which is in your application with file name) migrate

e.x: c:\ php C:\xampp\htdocs\advanced\php migrate

例如:c:\php C:\xampp\htdocs\advanced\php migrate

advanced is a name of application.

高级是应用程序的名称。