Libraries release fixes and new versions all the time. Composer gives you control over when and how you update.
See what is outdated
composer outdated
This lists your direct dependencies that have newer versions. Without any outdated packages, Composer prints nothing, or tells you everything is up to date.
Update everything allowed by composer.json
composer update
Composer looks for the newest versions that still satisfy your constraints in composer.json, installs them, and rewrites composer.lock.
Update one package
composer update monolog/monolog
Safer: only that package (and what it needs) changes. Use it when you want a specific fix without touching the rest.
update vs install
composer install | composer update | |
|---|---|---|
| Reads | composer.lock | composer.json |
| Result | Exactly the locked versions | The newest allowed versions |
Changes composer.lock | No | Yes |
| Use for | A fresh checkout, a server, CI | When you decide to upgrade |
On a live server, run composer install, never composer update. You want the versions you tested, not whatever is newest today.
Major updates
Constraints such as ^2.0 stop at the next major version (3.0). To move to a new major version, change the constraint yourself and read the package’s upgrade notes, because major versions may break things.
composer require league/commonmark:^3.0
A safe update routine
- Commit your work.
- Run
composer outdatedand read the changes that matter. - Run
composer update(or update one package). - Run your tests, and click through the app.
- Commit both
composer.jsonandcomposer.lock.
Security advisories
composer audit
Composer checks the installed versions against a list of known security problems and tells you which packages to update. Run it regularly and in your automated build.
When an update fails
Composer may report a conflict: package A needs B version 1, package C needs B version 2. Read the message. The usual solutions are to update the packages together, loosen a constraint, or pick a different package.
composer why-not vendor/package 2.0 # explains what blocks a version
composer why vendor/package # explains who needs a package
Dry run
composer update --dry-run
Shows what would change without changing anything.