Created
September 3, 2021 11:33
-
-
Save dr5hn/947124f34f8b67388f1a82067d7ba92f to your computer and use it in GitHub Desktop.
Install composer v1.x and v2.x simultaneously
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | |
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] | |
then | |
>&2 echo 'ERROR: Invalid installer checksum' | |
rm composer-setup.php | |
exit 1 | |
fi | |
# Version 1 | |
php composer-setup.php --quiet --install-dir=/usr/local/bin/ --filename=composer --version=1.10.22 | |
# Version 2 - If you want to install simultaneously | |
php composer-setup.php --quiet --install-dir=/usr/local/bin/ --filename=composer2 | |
# Check the versions if it is installed correctly | |
composer --version | |
# Uncomment this if you want to check composer2 version. | |
# composer2 --version | |
RESULT=$? | |
rm composer-setup.php | |
exit $RESULT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment