Dealing with Dependencies How to resolve composer package incompatibilities.


Introducing Shift

Get started with Shift in three simple steps.

Shift like a Pro

Tricks for working through your Shift quickly.

Maintaining Shiftability

Tips on how to keep your project upgradable.

Dealing with Dependencies

How to resolve composer package incompatibilities.

Continuous Shifts

Automate Shift to run continuously on your projects.

Configure Shift

Configure Shifts behavior by adding a .shiftrc file.


Transcript

Shift does it’s best to note any new version requirements when upgrading your application.

However, for older applications it’s likely that your dependencies will become incompatible.

The process for resolving these dependency conflicts can be a bit tedious. Especially if you’re not familiar with composer.

So you may end up in a situation where you’ve run your Shift and when you go to run composer install you receive something like this...

The first step is to wade through the output and determine which package is incompatible.

Often composer will complain more about the dependency it could not satisfy, and not the offending dependency.

If we scroll through we can normally find this at either the very bottom or somewhere in the middle.

Again, by process of elimination we can ignore statements about the Laravel or Illuminate packages as this is part of your upgrade.

Once you determine the package you can use composer to require it again. Note that if it’s a development dependency you’ll want to add the --dev option.

As soon as we see the version constraint appear, we can stop composer by pressing Ctrl + C.

This is a little trick to not only save time by preventing composer from trying to install all the dependencies, but also because when composer fails it reverts the updates to your composer.json file.

If you happen to not to catch it in time, you can scroll up and copy the version constraint from the output and manually updated your composer.json file.

Once we make this change we can attempt to run composer install again. If another package conflicts, repeat this process until composer install successfully install all of your dependencies.

If the composer require continues to fail, it is possible that the package dependency is truly incompatible with your upgraded project. You can determine this reviewing the project requirements on Packagist or the project source. Often, if a package no longer supports a recent version it will suggest an alternative package or native functionality which may replace its need.