Thanks to the ubiquity of Composer, a PHP application may depend on dozens of third-party packages, each of which will define their own dependencies. When an application is deployed and working as expected, it can be difficult to prioritize the development time for package updates with breaking changes, and you might find some dependencies have slipped a few major versions behind their current release. Nevertheless, even if all root dependencies are up to date, some packages inevitably become abandoned, drop version constraints, or add an incompatible dependency. The end result: upgrading to the latest PHP version (or other package) is blocked by a tangled web of interdependent version conflicts and incompatible vendor code.

Luckily for us, Composer is more than just install, require, and update, and we can use some of the lesser known functionality and behavior to untangle the web of conflicts and create forward-friendly migration path. We will cover:

Using the depends, and prohibits commands to understand package relationships
Using forked repositories and branch aliases to provide a compatible version of a package
Preventing unnecessary transitive dependencies from being installed and causing conflicts
Upgrading to the latest version of a package, by using Rector to downgrading it to your PHP version

Comments

Please login to leave a comment

Eric Poe at 11:23 on 24 Oct 2024

Dependency Hell is a non-fun problem to solve. I appreciated the live coding that demonstrated that this can be a problem even when you are a veteran of dealing with these conflicting dependencies.

One recommendation is to record the live-code and play that video so that you can talk about it while the ghost in the machine is doing the demo work during the presentation.

Technical issues aside, this talk is full of great information and strategies for upgrading PHP for any non-trivial applications. I'm currently in the midst of a PHP upgrade like the one described in this talk, and I've been using the strategies I picked up from Andy when I first saw this talk (Longhorn PHP 2023).

Chris Abbey at 08:58 on 25 Oct 2024

Lots of great tricks and tips here… Using two of my favorite tools no less, composer and rector. I’ve manually backed packages back to older php versions before, but never even thought to try using rector for it! And that composer replace trick… oh I am SO going to use that.