Composer
Published
Updated
🎼
Orchestrate PHP dependencies harmoniously.
Commit composer.json and composer.lock, keep vendor out of git. fortrabbit runs composer install with every git deployment.
Composer in the deployment
Composer installs the PHP dependencies listed in composer.json, in the exact versions locked in composer.lock. On fortrabbit, composer install runs as a build command with every git deployment, in a separate build container. The installed vendor folder then goes live with the code.
The stack detector adds the command when the repository has a composer.json:
composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
Composer and git
- Commit
composer.jsonandcomposer.lock. - Keep
vendorout of git with an entry in.gitignore. - Both files sit in the folder that gets deployed: the repository root, or the git source directory in a monorepo.
Run composer update locally, test, and commit the new composer.lock. The deployment installs exactly those versions.
Composer over SSH
composer install also runs over SSH, for example after an SFTP upload without git. It then runs in the environment itself, with the memory of the PHP plan. Never run composer update there: it resolves all versions from scratch, needs much more memory and changes the versions without testing.