Difference between composer install and composer update
suggest changecomposer update
composer update will update our dependencies as they are specified in composer.json.
For example, if our project uses this configuration:
"require": {
"laravelcollective/html": "2.0.*"
}
Supposing we have actually installed the 2.0.1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.2, if it has already been released).
In detail composer update will:
- Read
composer.json - Remove installed packages that are no longer required by
composer.json - Check the newest versions allowed by the constraints
- Install those versions
- Update
composer.lockto store the installed packages version
composer install
composer install installs the dependencies locked in composer.lock, without updating that file. If composer.lock is missing, Composer resolves composer.json and writes a new lock file, which is what composer update does.
In detail:
- Read
composer.lockfile - Install the packages specified in the
composer.lockfile
When to install and when to update
composer updateis mostly used in the ‘development’ phase, to upgrade our project packages.composer installis primarily used in the ‘deploying phase’ to install our application on a production server or on a testing environment, using the same dependencies stored in thecomposer.lockfile created bycomposer update.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents