简体   繁体   中英

Run yii commands from shell script

I am trying to make a script which automaticly loads a project from a git repository. I run exec() from a php file with name of the shell script as an argument. The script looks something like this:

git pull
php yii migrate

The git command works well, but the yii command is totally ignored. I'm doing this from the root of the directory of the yii site, so it should work, but it doesn't. How can I fix this?

if you are using Yii version 1.x, you have to run your command from inside protected directory

cd protected
php yiic.php migrate

First of all, if you want to run console application in Yii2, just use

yii <route> [--option1=value1 --option2=value2 ... argument1 argument2 ...]

Second: yii migrate is the defined console command to upgrade a database to its latest structure. So it probably does its work, but not that you want to.

Try to rename your console command.

Reference links to read:

Guide: console commands

Guide: migrations (part with yii migrate ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM