Last active
June 30, 2020 15:13
-
-
Save belfie13/09144ecd099b420192b8099f0bbd4850 to your computer and use it in GitHub Desktop.
Composer installation without using wget (not on macOS by default)
This file contains hidden or 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
#!/usr/bin/env sh | |
# Installation of __Composer__ to manage project dependancies | |
# save to and run script from `proj_path/scripts/` directory. | |
# verify download by checking file signature | |
EXPECTED_SIGNATURE="$(curl https://composer.github.io/installer.sig)" | |
# download the installer | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
# get the installers signature, its sha384 hash | |
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | |
# report error and exit | |
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] | |
then | |
>&2 echo 'ERROR: Invalid installer signature' | |
rm composer-setup.php | |
exit 1 | |
fi | |
# install Composer to a specific directory with `--install-dir` option | |
# remove `.phar` extension: (re)name the binary with `--filename` option. | |
#php composer-setup.php --install-dir="$(php -r "echo __DIR__;")" --filename=composer | |
php composer-setup.php --install-dir="$(php -r "echo realpath(__DIR__.'/../bin');")" --filename=composer | |
RESULT=$? | |
# remove the installation file | |
rm composer-setup.php | |
exit $RESULT |
This file contains hidden or 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
#!/usr/bin/env sh | |
# update the project local dependancies. | |
# save to and run script from `proj_path/scripts/` directory. | |
"$(php -r 'echo realpath(__DIR__."/../bin/composer");')" --working-dir="$(php -r "echo realpath(__DIR__.'/..');")" update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment