YumYumYum YumYumYum - 1 month ago 10
PHP Question

PHP - why is the composer command not found?

Why is the composer instruction from README, is failing when i apply as below?

enter image description here

Tried as below but failing:

# uname -a
Linux signal 3.10.0-123.8.1.el7.x86_64 #1 SMP Mon Sep 22 19:06:58 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

# php --version
PHP 5.4.16 (cli) (built: Oct 31 2014 12:59:36)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

# ls
LICENSE bootstrap.php detect.php index.php
README.md composer.json hooks templates

# composer create-project whichbrowser/server .
-bash: composer: command not found

# php composer create-project whichbrowser/server .
Could not open input file: composer


EDIT:

[root@signal wb]# php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
[root@signal wb]# php composer-setup.php
All settings correct for using Composer
Downloading 1.2.1...

Composer successfully installed to: /var/www/html/sip-phone/tls/website/wb/composer.phar
Use it: php composer.phar
[root@signal wb]# php -r "unlink('composer-setup.php');"
[root@signal wb]# php composer.phar create-project whichbrowser/server .
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Installing whichbrowser/server (v2.0.12)


[InvalidArgumentException]
Project directory ./ is not empty.


create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

[root@signal wb]#

Answer

Please try this:

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');"