Guides

How to check for breaking changes before composer update

By Server.Biz. Updated .

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:

So composer update with caret constraints should not cross a major version. "Should" is the important word:

Run your tests after every update, even a small one.

Where breaking changes are written down

For a jump of several versions, read the notes of every version in between, not only the newest.

A routine for a major upgrade

  1. 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.
  2. Read the upgrade guide and note which changes touch your code.
  3. Check what blocks the upgrade: composer why-not laravel/framework 13.0 lists the packages that do not allow the new version yet. Those need an update, a replacement or a wait.
  4. Change the constraint in composer.json and preview the result with composer update --dry-run.
  5. 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.
  6. 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.

Sources