Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Composer - Unable to install composer on macOS Sierra

I'm trying to install composer running the command provided on the getcomposer.org/download documentation site:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

But I get an error message saying:

Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in Command line code on line 1

Warning: copy(): Failed to enable crypto in Command line code on line 1

Warning: copy(https://getcomposer.org/installer): failed to open stream: operation failed in Command line code on line 1
Yoshihiros-MacBook-Pro:~ yoshihiro$ php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Warning: hash_file(composer-setup.php): failed to open stream: No such file or directory in Command line code on line 1
Installer corrupt
Warning: unlink(composer-setup.php): No such file or directory in Command line code on line 1

Yoshihiros-MacBook-Pro:~ yoshihiro$ php composer-setup.php
Could not open input file: composer-setup.php

I'm also trying to install it globally but I can't get out of this message. Please help D:

like image 405
Yoshihiro Ortiz Avatar asked Oct 23 '16 17:10

Yoshihiro Ortiz


People also ask

Why is Composer not installing?

Why is composer not installing? Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php — –check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

Do you need PHP to install Composer?

Important! If you installed Composer locally, you need to use php composer. phar command within the same directory where it was installed in order to use Composer.

How install Composer install?

Step 1: Navigate to the official composer website. Step 2: Then click on the Download button. Step 3: Then click on the Composer-Setup.exe & download the file. Step 4: Then click on “Install for all users”.


1 Answers

I had same issues but this what I did:

  • I copy paste this into the terminal php -r "copy('http://getcomposer.org/installer', 'composer-setup.php');" on the terminal which download the composer to the directory where you are currently In.

(the problem was causing because of the https protocol)

  • And then php composer-setup.php --install-dir=/usr/local/bin --filename=composer run this command, which installs the Composer to my bin folder so that i could run it globally.

  • Then you have to unlink the composer php -r "unlink('composer-setup.php');"

  • Finally check the see the Composer installed composer -V.

Good Luck !

like image 194
AsimRazaKhan Avatar answered Oct 10 '22 17:10

AsimRazaKhan