How to check for breaking changes before composer update
Most Composer updates change little. The ones that break things are usually major releases, and they come with an upgrade guide. This guide covers how to tell the two apart and what to read before you run composer update.
What your constraints already protect you from
PHP packages use semantic versioning: MAJOR.MINOR.PATCH. A patch release fixes bugs, a minor release adds features, and only a major release may remove or change what existed before. Composer's caret constraint builds on that:
^13.2accepts 13.2.0 and everything up to, but not including, 14.0.0.^0.3accepts 0.3.0 up to 0.4.0. Before 1.0, a minor release counts as a major one.~1.2.3accepts 1.2.3 up to 1.3.0, so only patch releases.
So composer update with caret constraints should not cross a major version. "Should" is the important word:
- Not every package follows semantic versioning strictly.
- A bug fix changes behaviour, and sometimes your code relied on the bug.
- Minor releases add deprecations. They do not break anything yet, but they are what the next major removes.
Run your tests after every update, even a small one.
Where breaking changes are written down
- Upgrade guides. Laravel publishes one per major release in its documentation, with each change marked by how likely it is to affect you. Symfony keeps an UPGRADE file per major version in its repository.
- Release notes and changelogs. The GitHub release of each version, or a CHANGELOG.md in the repository. Look for headings such as "Breaking changes", "Removed" or "BC break".
- Deprecation notices in your own logs and test output, which list the code you have to change before the next major.
For a jump of several versions, read the notes of every version in between, not only the newest.
A routine for a major upgrade
- Fix deprecations on your current version first. Symfony removes in each major exactly what the last minor of the previous one deprecated, so a project without deprecation notices on 7.4 is ready for most of 8.0. In Laravel, set a deprecations log channel to collect them.
- Read the upgrade guide and note which changes touch your code.
- Check what blocks the upgrade:
composer why-not laravel/framework 13.0lists the packages that do not allow the new version yet. Those need an update, a replacement or a wait. - Change the constraint in composer.json and preview the result with
composer update --dry-run. - Update with
composer update, then run your tests and static analysis. PHPStan, or Larastan for Laravel, finds calls to methods that no longer exist and changed signatures that tests can miss. - Deploy the upgrade on its own, without feature work in the same release, so a problem points to one cause.
Tools such as Rector can apply many of the mechanical changes for you. Review what they change like any other code.
One major at a time
Upgrading from 11 to 13 in one step means reading two upgrade guides at once and debugging changes from both. Going through 12 first takes longer on paper and usually less time in practice, because every step can be tested on its own.
How vgit helps
vgit reads the release notes, changelogs and upgrade guides of the versions between yours and the latest, and summarises breaking changes, deprecations and security fixes in plain language. Every summary shows a confidence level and links to its source, because a summary is only as complete as the notes behind it. Use it to see which upgrades need work before you start, and read the source before you upgrade.