Home » Php » sh: php: command not found in git bash windows 8

sh: php: command not found in git bash windows 8

Posted by: admin July 12, 2020 Leave a comment


I’m running php composer.phar install from git bash CLI and it shows sh:php: Command not found.
Though I have set environment variable path to my wamp/bin/php/php5.4.16/

How to&Answers:

You are required to put the directory that has php.exe in your WAMP installation into environment variable PATH. It is generally like C:\wamp\bin\php.

Where \php\ is the directory containing php.exe.


  1. Set php env. variable as mentioned here. (you can test it easily using this command:                   php -r "echo 1;" or php -v)
  2. restart git shell
  3. if composer.phar does not exists, run this (more info):                                                                   
    php -r "readfile('https://getcomposer.org/installer');" | php

  4. run php composer.phar install finally

Run php without git shell:

  1. Locate C:\wamp\bin\php
  2. Hold SHIFT and click with right mousebutton on folder phpX.Y.ZZ
  3. Select Open command prompt window here
  4. run any php command like php parameters


Whether you are using gitbash or cmd you should run it as an administrator. Navigate to your project then type the command “composer install” it will work. Mine worked just fine.