Composer How to fix Your requirements could not be resolved to an installable set of packages

Tue, 08/04/2020 - 08:40

Quite often when upgrading packages in composer you will find you come across this error.

Your requirements could not be resolved to an installable set of packages.

This can be perplexing as you will try to update both the packages that are conflicting but they are dependent on the each other's versions leaving you in a loop.

To fix this you going to have to update both the packages at the same time, follow these steps and you should be able to get through the updating of the packages.

First delete the folder directorys where the packages are located.

Then lets remove the composer files. Why? composer.lock has a recorded version of both of the packages and will stop your update.

$ rm composer.lock

Remove the package lines in the composer file, why? even with removing the composer.lock file you will still get a conflict.

Edit composer.json in your IDE.

$ vi composer.json 

Find the lines under  "require": { } and delete the package name and version. 

Finally, remove the vendor directory, I found this can be optional in this case but for reference, I would delete this if I am running updates of all the packages.

$ rm -R vendor

Now you can add the updated packages in the order of reliance.

$ composer require 'Packagetype/packagenamefirst'

$ composer require 'Packagetype/packagenamesecond'

Thats it you should be back up and running.