phpatch.com

← phpatch.com home

Patch the Other Half: Composer Audits and Dependency Updates

By PHP Patch Assurance · Last updated: 2026-11-20 · Plain-text version

A PHP site has two independent patch streams: the interpreter (PHP itself) and the libraries the application is built from, managed by Composer. Patching one says nothing about the other. <code>composer audit</code> — built into Composer since 2.4 — compares the exact versions pinned in your composer.lock against the Packagist security advisory database and reports the ones with known vulnerabilities, with a non-zero exit code when it finds any.

Run the audit

In the project root: composer audit. It reads composer.lock — the versions actually deployed, not the ranges composer.json permits — and lists each advisory with the affected package, the vulnerable version range, and the fixed version. No lock file, no audit: if the project has no composer.lock, run composer install once to create it, and commit it to version control. The lock file is the record of what is running; it belongs in the repo.

Read composer outdated alongside it

composer outdated shows where newer releases exist, split into direct dependencies (the ones your composer.json names) and transitive ones (theirs). Audit findings on a transitive dependency are fixed by updating the direct dependency that pulls it in, or by updating the transitive package within the range its parent allows — composer update vendor/package handles both cases without touching anything else.

Update deliberately

For a security fix, update the named package only: composer update vendor/package, then run the test suite and the post-patch health checks. A blanket composer update that moves forty packages to fix one advisory turns a security task into a debugging session. Never edit files under vendor/ by hand — the next install erases it, and the lock file will still claim the vulnerable version is deployed.

Pin the platform you deploy to

Set config.platform.php in composer.json to the PHP version production actually runs. Without it, Composer resolves dependencies for the PHP on the machine doing the resolving — a laptop on 8.4 will happily lock packages a production server on 8.2 cannot run, and the audit will be checking a site that does not exist.

Make it routine, not an event

Run composer audit in CI and let its non-zero exit code fail the build: a new advisory against an old lock file then surfaces the day it is published, not the day someone remembers to look. Recent Composer versions can also flag abandoned packages in the audit, which is your early warning that a dependency's fixes have stopped coming at all.

Check your site free Patch service

This guide pairs with the patch service.

Frequently asked questions

Does composer audit check my PHP version too?

No. It checks the libraries in composer.lock. The interpreter is a separate stream: check it with <a href='/guides/check-php-version'>the version checks</a> and keep it inside its support window per <a href='/guides/php-release-lifecycle'>the lifecycle dates</a>. A clean audit on an end-of-life PHP is still an exposed site.

The fix for my advisory is a new major version. Now what?

Do it in staging, read the package's upgrade notes before updating, and expect breaking changes — that is what the major number means. The alternative to a planned major upgrade is running a known-vulnerable version indefinitely, which is not a safer plan, just a slower one.

Audit is clean but outdated shows red. Am I safe?

Against known advisories, yes, today. The red entries are versions you will have to move to eventually; moving in small steps while nothing is on fire is how you avoid the major-version jump under pressure later.

← Guides