Skip to content

Instantly share code, notes, and snippets.

@vinaydotblog
Last active April 17, 2023 11:08
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save vinaydotblog/6896317 to your computer and use it in GitHub Desktop.
Save vinaydotblog/6896317 to your computer and use it in GitHub Desktop.
Installing composer using curl
# Goto a directory you can write to:
cd ~
#get composer:
curl -s https://getcomposer.org/installer | php
# move composer into a bin directory you control:
sudo mv composer.phar /usr/local/bin/composer
# double check composer works
composer about
# (optional) Update composer:
sudo composer self-update
@dimkir
Copy link

dimkir commented Mar 13, 2017

I guess it is better to use curl -sS .... | php because then you will get the error message in case curl fails. (also error will be sent to stdout thus it won't be sent to php interpreter)

Here is info on the related curl command line switches

     -s, --silent
              Silent  or  quiet  mode. Don't show progress meter or error mes‐
              sages.  Makes Curl mute. It will still output the data  you  ask
              for, potentially even to the terminal/stdout unless you redirect
              it.

       -S, --show-error
              When  used  with  -s  it  makes curl show an error message if it
              fails.

@BerkhanBerkdemir
Copy link

@dimkir, @vinnizworld
Easiest way to download and move file to /usr/local/bin folder.

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
composer about

@TingLiu6
Copy link

Hi All,
I run above command on ubuntu 14, it fails, do you know how to fix this issue on ubuntu?

root@Cmpt2:/tmp# curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
All settings correct for using Composer
Downloading...
The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Retrying...
The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Retrying...

@taragurung
Copy link

I was running this on docker alpine container. Was fine and now, all of a sudden its problematic.

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Now i got this issue```

bash: php: command not found
curl: (23) Failed writing body (0 != 16133)

@Yannick243
Copy link

First install php then try to run this command
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Copy link

ghost commented Apr 7, 2020

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Will failed with error: The installation directory "/usr/local/bin" is not writable. So, need run php with sudo:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

@w3servicesdotnet
Copy link

Usage: php
php -[b|c|n|h|i|q|s|v|?] [] [args...]
Run in LSAPI mode, only '-b', '-s' and '-c' are effective
Run in Command Line Interpreter mode when parameters are specified

-b address:port| Bind Path for external LSAPI Server mode
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-h This help
-i PHP information
-l Syntax check
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-? This help

args... Arguments passed to script.
curl: (23) Failure writing output to destination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment