How to co-install composer 1 and composer 2

If you followed the steps at How to set-up a Drupal or WordPress site locally using Docker to set-up a local Drupal 8 site using docker, you will find that the PHP container has composer2 and that Drupal 8 is not compatible with it.

The easiest way to get composer 1 up and running when one already has composer 2 installed is by running this command: composer self-update --1 It will replace composer 2 completely though.

If for some reason you need to have both composer 1 and composer 2 co-installed you can run these simple commands in the terminal (Assuming you have composer 2 already working):

sudo cp `which composer` /usr/local/bin/composer1 && sudo composer1 self-update --1
sudo composer self-update --2 && sudo ln -s `which composer` /usr/local/bin/composer2

After running the commands above you should be able to run composer1 or composer2 instead of just composer, based on one’s needs.

Example to use composer 1: composer1 install

Example to use composer 2: composer2 install


Posted

in

by