When you install
or update
a project with composer, you can tell it to skip the development related dependencies (tests, build tools, etc.) with th
This was really annoying, so I finally wrote a simple bash script which asks about environment and run correct command:
#! /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.)
Saved it in bin/deploy
in project and added execute permissions. So now I'm using bin/deploy
instead of composer install
:
I also put other common tasks there (pull changes from VCS, clear cache, run migrations, etc.), so I have even less things to do and remember during deployment :).