Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install old version of composer [duplicate]

I want to install old version of composer. My commands are:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --version=1.4.1
php -r "unlink('composer-setup.php');"

But it didn't install composer. I check with the command composer -v but unfortunately it didn't work. How can I do this?

like image 578
asma Lri Avatar asked Dec 14 '19 14:12

asma Lri


People also ask

How do I downgrade my composer from 2 to 1?

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies.

How do I install a specific version of composer package?

If you were hoping to switch to a specific version and check-in your composer. lock file, you can, but you'd have to use composer require and then revert the change to composer. json afterwards.


3 Answers

These commands will install composer binary in composer.phar file in current working directory. You may try to verify this by running php composer.phar -v command. composer command will most like point to some global installation in your system - you need to move new binary to correct place, so it could be recognized as global command (see docs):

mv composer.phar /usr/local/bin/composer

If you have already Composer installed, you should able to use self-update command to downgrade to any version:

composer self-update 1.4.1

or

sudo -H composer self-update 1.4.1
like image 117
rob006 Avatar answered Sep 20 '22 03:09

rob006


If you came here searching for downgrading from composer 2.0 to 1.0

composer self-update --1

like image 25
goellner Avatar answered Sep 24 '22 03:09

goellner


Curl can be used to download a specific version:

curl -O "https://getcomposer.org/download/1.10.17/composer.phar"
chmod a+x composer.phar
sudo mv composer.phar /usr/local/bin/composer
like image 38
Amadu Bah Avatar answered Sep 23 '22 03:09

Amadu Bah