How to install composer on your mac, when '-bash: command: composer not found' error occurs
If you see this error, it means that your os can't identify composer.phar globally. There lot of reasons to occur this error. There are lot of solutions on internet also. In my case the solutions have not been worked out. And that's why i am writing this post.
Step 1: Firstly you need to check out that, has '/usr/local/bin' this path been declared globally? to do so run the command 'echo $PATH', If you don't see like this '/usr/local/bin' then the path is not declared properly. We have to declare the path.
Step 2: just run this command 'export PATH=$PATH: /usr/local/bin'
Step 3: run it 'source ~/.bash_profile'
Step 4: clear the terminal and run 'php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');
Step 5: run this command 1. php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Step 6: this is very vital step for solving the problem. run the following command
'php composer-setup.php --install-dir=/usr/local/bin --filename=composer'
Step 7: run the command 'php -r "unlink('composer-setup.php');"' and clear the terminal and run 'composer' command anywhere on your mac os it will be fantastic.
Step 1: Firstly you need to check out that, has '/usr/local/bin' this path been declared globally? to do so run the command 'echo $PATH', If you don't see like this '/usr/local/bin' then the path is not declared properly. We have to declare the path.
Step 2: just run this command 'export PATH=$PATH: /usr/local/bin'
Step 3: run it 'source ~/.bash_profile'
Step 4: clear the terminal and run 'php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');
Step 5: run this command 1. php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Step 6: this is very vital step for solving the problem. run the following command
'php composer-setup.php --install-dir=/usr/local/bin --filename=composer'
Step 7: run the command 'php -r "unlink('composer-setup.php');"' and clear the terminal and run 'composer' command anywhere on your mac os it will be fantastic.
Comments
Post a Comment