I'm trying to understand this part: http://getcomposer.org/doc/02-libraries.md#lock-file
this lock file will not have any effect on other projects that depend on it. It only has an effect on the main project"
Does that mean that if project P depends on library A, and library A depends on library B v1.3, project P won't care about the version of library B, and will possibly install B 1.4 instead? What's the point then?
Or does it mean the opposite, as one would expect from a dependency manager?
composer.lock
records the exact versions that are installed. So that you are in the same versions with your co-workers.composer install
composer.lock
filecomposer.lock
file (Usingcomposer update
)composer.lock
filecomposer update
composer.json
filecomposer.lock
file with installed versionsSo in a simple check list.
If you want to keep all co-workers in the same versions as you...
composer.lock
to GIT (or vcs you have)composer.lock
filecomposer install
to get the correct dependenciesIf you want to Upgrade the system dependencies to new versions
composer update
composer.lock
file with newest versionscomposer install
Following will be a very good reading
https://blog.engineyard.com/2014/composer-its-all-about-the-lock-file
Enjoy the power of
composer.lock
file!Composer dependencies are defined in
composer.json
. When running composer install for the first time, or when running composer update a lock file calledcomposer.lock
will be created.The quoted documentation refers to the lock file only. If your project P depends on library A and A depends on B v1.3.***, then if A contains a lock file saying someone ran "composer update" resulting in B v1.3.2 being installed, then installing A in your project P might still install 1.3.3, as the
composer.json
(not.lock
!) defined the dependency to be on 1.3.*.Lock files always contain exact version numbers, and are useful to communicate the version you tested with to colleagues or when publishing an application. For libraries the dependency information in
composer.json
is all that matters.The point of the lock file is to record the exact versions that are installed so they can be re-installed. This means that if you have a version spec of 1.* and your co-worker runs
composer update
which installs 1.2.4, and then commits the composer.lock file, when youcomposer install
, you will also get 1.2.4, even if 1.3.0 has been released. This ensures everybody working on the project has the same exact version.Read more here Composer: It’s All About the Lock File