Shift with red gradient lettering

Dealing with Dependencies

How to resolve composer package incompatibilities.

Watch Next

Upgrading old Laravel applications

Speed up the upgrade process even more with tips from the creator of Shift.

Maintaining Shiftability

Tips on how to keep your project upgradable.

Enabling automation for releases

Set up your repositories to automatically release Pull Requests for new releases.

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.

Sign in with any of the following services to connect Shift with your Laravel project.


Don't use one of these services?

Temporarily push your project to a free, private repository on one of these cloud-based services or upgrade your project locally with Shift for Docker.