这真的很烦人,所以我终于写了一个简单的bash脚本,询问环境并运行正确的命令:
#! /bin/bash
read -p "Which environment use to deploy: (P)roduction (T)est (D)ev? (p/t/d): " -n 1 -r
echo
if [[ $REPLY =~ ^[^PpTtDd]$ ]]; then
echo "Incorrect environment";
exit 1;
fi
# tasks to run before composer install (svn up/git pull)
if [[ $REPLY =~ ^[Pp]$ ]]; then
composer install --prefer-dist --no-dev --classmap-authoritative
elif [[ $REPLY =~ ^[Tt]$ ]]; then
composer install --prefer-dist --classmap-authoritative
elif [[ $REPLY =~ ^[Dd]$ ]]; then
composer install
fi
# additional tasks after composer install (clear cache, migrations, etc.)
将其保存在项目中并添加了执行权限。所以现在我用的是代替:bin/deploy
bin/deploy
composer install
我还把其他常见任务放在那里(从VCS拉取更改,清除缓存,运行迁移等),所以我在部署:)期间要做的事情更少,要记住的事情更少。