Running PHP works in Command Prompt but not Git Bash
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:
Now, if I run this through command prompt it works perfectly fine:
I've set the correct PATH variable for PHP and triple checked this:
What can I do to get PHP working through my Git Bash command line?
EDIT
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/Users/James.b/bin
/mingw64/bin
/usr/local/bin
/usr/bin
/bin
/mingw64/bin
/usr/bin
/c/Users/James.b/bin
/c/ProgramData/Oracle/Java/javapath
/c/WINDOWS/system32
/c/WINDOWS
/c/WINDOWS/System32/Wbem
/c/WINDOWS/System32/WindowsPowerShell/v1.0
/c/Go/bin
/c/wamp64/bin/php/php7.0.10
/c/ProgramData/ComposerSetup/bin
/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
/cmd
/c/Users/James.b/AppData/Local/Microsoft/WindowsApps
/c/Users/James.b/AppData/Roaming/Composer/vendor/bin
/c/wamp64/bin/php/php7.0.10
/usr/bin/vendor_perl
/usr/bin/core_perl 8 3 Answers
What can I do to get PHP working through my Git Bash command line?
alias php='/c/wamp64/bin/php/php7.0.10/php' 2 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:).
2From your screenshot, we know you are using Windows. There is a solution as below:
Open
git bashCreate
.bashrcfile in the home directory (~)
cd ~
touch .bashrc- 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