I've recently got a new laptop and have been in the process of setting it up.

I've installed WAMP, which is what I use to do my PHP development (installs Apache2, MySql, and PHP).

I also like to use Git Bash as my preferred command line tool, however when I try to do anything with PHP through the command line - I get a strange result; nothing happens and there is no error:

enter image description here

Now, if I run this through command prompt it works perfectly fine:

enter image description here

I've set the correct PATH variable for PHP and triple checked this:

enter image description here

What can I do to get PHP working through my Git Bash command line?


Output of ll /c/wamp64/bin/php/php7.0.10/php:

-rwxr-xr-x 1 james.b 1049089 122368 Aug 18  2016 /c/wamp64/bin/php/php7.0.10/php*

Output of echo $PATH | tr ":" "\n":

/c/Program Files/Microsoft/Web Platform Installer
/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn
/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn
/c/Program Files/Microsoft SQL Server/120/Tools/Binn
/c/Program Files/Microsoft SQL Server/120/DTS/Binn
/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio
/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn
  • Type which php just to make sure, or launch php with the full path.
    – simlev
    Commented Aug 7, 2017 at 9:59
  • @simlev that returns /c/wamp64/bin/php/php7.0.10/php which is the correct directory? Should the php at the end be php.exe as I am on windows?
    – James
    Commented Aug 7, 2017 at 10:01
  • 1
    It looks correct. Try with the full path /c/wamp64/bin/php/php7.0.10/php -v, or go into that directory and type ./php -v.
    – simlev
    Commented Aug 7, 2017 at 10:11
  • @simlev OK that worked. Is there something I can do to get it working? Otherwise I can just setup an alias for it
    – James
    Commented Aug 7, 2017 at 10:18
  • Yes, I suggest you simply alias it.
    – simlev
    Commented Aug 7, 2017 at 10:24

4 Answers 4


What can I do to get PHP working through my Git Bash command line?

alias php='/c/wamp64/bin/php/php7.0.10/php'
  • do we need to every time we open git bash? Or we can add it in some .profile file?
    – Knight017
    Commented May 1, 2019 at 7:18
  • 2
    @Knight017 add it to ~/.bashrc.
    – simlev
    Commented May 2, 2019 at 14:03

I entered the following command in git bash and it worked.

alias php='/d/xampp/php/php.exe'

Note: My xampp is installed in "D" drive (D:).

  • How is your answer better/different than the other one?
    – gronostaj
    Commented May 24, 2018 at 6:58
  • 1
    There is a difference in the path. In my case, I needed to enter the full path includingphp.exe. Commented May 24, 2018 at 7:00

From your screenshot, we know you are using Windows. There is a solution as below:

  1. Open git bash

  2. Create .bashrc file in the home directory (~)

cd ~
touch .bashrc
  1. Add alias into the .bashrc file
alias php='winpty /c/wamp64/bin/php/php7.0.10/php'

c/wamp64/bin/php/php7.0.10/php => stands for C:\wamp64\bin\php\php7.0.10\php on Windows

  • 1
    How is this any different to the existing answers?
    – James
    Commented Oct 8, 2020 at 19:46
  • The alias definitions are held in memory, so there isn't really any strong performance argument for or against defining them in .bashrc. See: unix.stackexchange.com/a/347198/190552 Commented Oct 9, 2020 at 4:08

My git bash was pointing to PHP in my XAMMP folder. Reinstalling XAMMP corrected the issue for me.

download XAMMP https://www.apachefriends.org/download.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .