yii2 installation - migrate command not working

2020-07-14 12:32发布

问题:

I am trying to install yii2 in ubuntu.

yii2 migrate command not working

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

回答1:

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 init command and select dev as environment.

php /path/to/yii-application/init

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

Apply migrations with console command:

yii migrate

or for windows:

php yii migrate

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

ref [Yii2 Documentation]



回答2:

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



回答3:

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 working If You'are lazy of afraid to do it for some reasons, just copy "yii" file and /config/*-local.php files into Your project directory.



回答4:

For init use following command on windows

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

advanced is a name of application.



回答5:

you can use php yii2 migrate

this worked for me