1
0
Fork 0

Update how-to-install-composer-programmatically.md

docs: update installation instructions for Composer

- Added a new section on installing Composer programmatically using PHP.
- Updated examples to reflect the latest best practices.
- Fixed typos and improved formatting for better readability.
pull/12256/head
Seth Landry 2024-12-28 18:31:57 -06:00 committed by GitHub
parent fb397acaa0
commit 75cd2e20a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@ it should not be relied upon in the long term.
An alternative is to use this script which only works with UNIX utilities:
```shell
<!-- Please remember to select the appropriate branch:
#!/bin/sh
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
@ -20,6 +21,25 @@ then
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULTFor bug fixes pick the oldest branch where the fix applies (e.g. `2.4` if that version is affected, `1.10` if it is a critical fix that should be fixed in Composer 1, otherwise `main`)
For new features and everything else, use the main branch. -->
!/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