composer.lock
The lock file records the exact version of every installed package and its dependencies. It ensures reproducible builds across all environments.
The lock file records the exact version of every installed package and its dependencies. It ensures reproducible builds across all environments.
# Always commit composer.lock
git add composer.lock
# Install exact locked versions (CI, production)
composer install --no-dev --no-interaction
# Update a single package
composer update vendor/package
# After update, review the diff
git diff composer.lock | grep "\"version\""
A differing lock file between environments is the most common cause of "works on my machine" bugs.