Use this script to quickly and easily run composer commands without the need for it being installed on the host machine.
This concept is used in Google Cloud's Cloud Build whereby the working directory (where your php code is) is mounted inside a docker container to execute isolated steps in a build pocess.
Run the script from within a project to install and maintain dependencies or from a parent directory to use the create-project
command.
To execute a command:
./composer-command.sh {{ composer commands }}
the {{ composer commands }}
above get passed to composer for execution (eg: install
)
Some suggested composer options (add on the end of your commands):
--dev
for development
--prefer-dist --optimize-autoloader
for production
--ignore-platform-reqs
for all platforms so composer does not check the "platform" (as that is the composer docker container)
Note: the script always includes the --verbose
command - remove this if you want the commands to be quieter.
Install dependencies in your dev box (run this within your project folder) ./composer-command.sh install --dev --ignore-platform-reqs
Install Laravel (run this from a parent directory) ./composer-command.sh create-project laravel/laravel example-app --ignore-platform-reqs