Forrest logo
back to the composer tool

composer:tldr:9d9e7

composer: Update composer lock only after updating `composer.json` manually.
$ composer update --lock
try on your machine

The command "composer update --lock" is used in the context of managing dependencies in a PHP project using Composer, which is a package manager for PHP.

In detail:

  • "composer" refers to the Composer command-line tool.
  • "update" is the Composer command used to update dependencies.
  • "--lock" is a flag that tells Composer to update the lock file.

When you run "composer update" without the "--lock" flag, Composer will update the versions of the dependencies in the project's "composer.json" file to their latest available versions, disregarding the existing "composer.lock" file. However, it will generate a new "composer.lock" file that reflects the updated dependency versions.

On the other hand, when you run "composer update --lock", Composer will update the versions of dependencies based on the existing "composer.lock" file. It will not look for newer versions of the packages, but instead, it will install the exact versions specified in the "composer.lock" file. This option is useful when you want to ensure that the project uses the same dependency versions across different environments or during deployment, making it more consistent and stable.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the composer tool