Engineering 4 min read Updated
Keeping dependencies up to date, one step at a time
In short
Commit the lock file, audit what you actually install and update one package at a time with tests, so that fixes arrive without breaking the release.
Most of the code a PHP application runs was written by someone else. Keeping dependencies current is therefore part of security and maintenance, not an optional extra. The OWASP page on software supply chain failures ranks as category A03 in the 2025 Top 10, and it names vulnerable, unsupported or out-of-date software as a risk indicator. Start with exact versions in the lock file and a regular audit, then update in small steps. For the platform version itself, read the article on planning a PHP version upgrade.
Exact versions live in the lock file
The composer update command selects the latest versions that composer.json allows, and writes the exact versions it chose into composer.lock. The Composer basic usage guide advises committing the lock file, for applications and for libraries alike. Developers and deployments then install the same versions, because install reads the versions recorded in the lock file rather than selecting them again. If composer.json and the lock file disagree, install shows a warning. In continuous integration, treat that warning as a failed check.
Audit the packages you actually install
The audit command checks installed packages against dependency policies. By default it looks up security advisories through the Packagist API, and it can also report abandoned packages and packages flagged as malware. The --locked option audits the lock file regardless of what sits in the vendor folder. The command exits with 0 when it finds no issues, and with 1 when it finds matching packages or fails because a required package is missing. The Composer command-line reference describes these options.
| Command | What it does |
|---|---|
| composer install | Installs the exact versions listed in composer.lock. |
| composer update | Selects the latest versions allowed by composer.json and rewrites composer.lock. |
| composer update vendor/package | Changes only the named package. |
| composer audit | Checks installed packages for advisories, abandonment and malware flags. |
A clean audit does not prove that a package is safe. It reports only what the advisory data contains at the time of the check, so run it regularly rather than once. Run it in an environment that matches your deployment, so the result describes what will actually ship.
Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea
Update in small, tested steps
OWASP warns that risk grows when a team does not fix or upgrade its platform, frameworks and dependencies in a timely, risk-based way. It also advises watching libraries that are no longer maintained, or that have stopped issuing security fixes for older versions. In practice, that means updating often and in small pieces:
- Update one package, or one closely related group, per change, so that any failure has an obvious cause.
- Run the test suite and the main user journeys after each change.
- Commit the updated composer.lock together with the change that needed it. The history then shows which version arrived, and why.
- Read the changelog before moving to a new major version. Major versions may contain breaking changes, as explained in the article on versions and changelogs.
- Note any package you hold back on purpose, with the reason, so the next review knows what to revisit.
Checklist for each update
Work through these points for every dependency change:
- Run composer audit against the lock file, and record the result.
- Decide which packages to update and why. Write the reason in the change.
- Update one package or one group, then review its changelog for breaking changes.
- Run the tests, and check the main pages and forms by hand.
- Commit composer.json and composer.lock together, and deploy with a rollback plan ready, as described in the article on releases and rollbacks.
- Schedule the next review, so that dependencies do not age unnoticed.
Common questions
- Should composer.lock be committed?
- Yes. The Composer basic usage guide advises committing the lock file for applications and for libraries alike, so that everyone installs the same versions.
- Does a clean composer audit mean my dependencies are safe?
- No. The audit reports only what the advisory data contains at the time of the check, so it should be run regularly rather than once.
- Should every dependency be updated as soon as possible?
- Not automatically. Update in small, tested steps and read the changelog first, because a new major version may contain breaking changes.
Sources
- A03:2025 Software Supply Chain Failures, OWASP Top 10:2025. Accessed 24 November 2026
- Basic usage, Composer. Accessed 24 November 2026
- Command-line interface, Composer. Accessed 24 November 2026
Further reading
-
Planning a PHP version upgrade
Plan an upgrade around the support dates and the changes that affect your code, and keep a way back to the previous version.
-
Versions and changelogs that readers can follow
Raise MAJOR for incompatible public changes, MINOR for compatible new features and PATCH for compatible fixes, and record each release in a changelog people can read.
-
Accepting file uploads safely in PHP
Check every upload on the server, accept only the file types the application needs, and store the file where no visitor can run it or fetch it directly.
Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea