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?
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.
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.
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
If you came here searching for downgrading from composer 2.0 to 1.0
composer self-update --1
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With