When a development team is working on a PHP project that uses Composer with Git, it often happens that there are conflicts on the composer.lock file, on the "content hash" line.

This happens, for example, when two people add different dependencies. Composer will calculate a new hash (which consists of a single string) from the set of installed packages for each person, giving two different values. The problem comes when merging the work. Most of the content of the two files (composer.json and composer.lock) can be merged by Git with no problem, but the final set of installed packages, being an entirely new set, will imply a new hash value that Git doesn't know how to calculate.

To solve this, Composer provides a way to update the lock file from the packages currently installed, including the content hash value:

$ composer update --lock

This does not try to update every package to the latest versions (as composer update would do).

Previous on PHP
Mastodon Mastodon