Skip to content

Instantly share code, notes, and snippets.

@superbiche
Created February 5, 2022 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superbiche/2c00f6c32a315459f2f2bb054c7e445b to your computer and use it in GitHub Desktop.
Save superbiche/2c00f6c32a315459f2f2bb054c7e445b to your computer and use it in GitHub Desktop.
Install Composer programmatically
#!/bin/sh
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
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
php composer-setup.php --quiet
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