Composer error while setup in macbook and solution
While install composer, I am facing above error.
Command
jaybharat@Jays-MacBook-Pro ~ % sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Password:
sudo: php: command not found
zsh: command not found: php
zsh: command not found: php
zsh: command not found: php
Composer error screenshot here
Error above
Solution step 1/2:
First you have to install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Source: https://brew.sh/
screenshot solution1
Solution step 2/2:
jaybharat@Jays-MacBook-Pro ~ % brew install php
Second you have to install PHP
screenshot solution2
screenshot here
Some time you may face error while installing any package using composer
example below I am trying to download google SSO
jaybharat@Jays-MacBook-Pro bharatbaba.com % sudo composer require google/apiclient:"^2.0"
sudo: composer: command not found
and I was getting error as above.
So, inthis case you have to run this query
jaybharat@Jays-MacBook-Pro bharatbaba.com % which composer
composer not found
jaybharat@Jays-MacBook-Pro bharatbaba.com % sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Then
jaybharat@Jays-MacBook-Pro bharatbaba.com % sudo mv composer.phar /usr/local/bin/composer
jaybharat@Jays-MacBook-Pro bharatbaba.com % which composer
/usr/local/bin/composer
Now the problem is solved.
Share on Facebook
Page views:99