Jesús Amieiro

Install Composer 2 in a machine with Composer 1

In October 2020, Composer 2 was released. In some servers, I have some projects that need Composer 1 and others that need Composer 2. I will go to explain how to have both versions on the same server.

When I execute “composer –version”, I get the version 1:

$ composer --version
Composer version 1.6.5 2018-05-04 11:44:59

To install the version 2, I execute this command:

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer2

Now, when I execute “composer2 –version”, I get the version 2:

$ composer2 --version
Composer version 2.1.3 2021-06-09 16:31:20

If I execute “composer –version”, I get the version 1, so I don’t break any previous script.

$ composer --version
Composer version 1.6.5 2018-05-04 11:44:59

Now I can execute Composer 2 on this server, executing “composer2”

$ composer2 
Exit mobile version