php is not recognized as an internal or external command (windows 7)

4

1

I added php to the PATH environment var. Showing here my last three entries in the path input:

C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseGit\bin;C:\xampp\php\

Somehow when I run php -v in the cmd I still get the not recognized as an internal or external command error.

Any ideas on how should I fix this?

xampp php folder screenshot

Zubzob

Posted 2013-03-12T22:26:46.887

Reputation: 191

2Check if php.exe is in C:\xampp\php\ or some subfolder there – None – 2013-03-12T22:28:15.917

Pretty sure it's there. Added a screenshot. – None – 2013-03-12T22:38:42.703

Reopen your cmd window after you have added the path, then the change will have an effect – Michel Feldheim – 2013-03-12T22:44:51.553

I think you need to restart the computer to take effect the changes you have made in path. – The Alpha – 2013-03-12T22:47:52.010

I've restarted my PC multiple times after modifying the variable system with no luck. – None – 2013-03-12T22:49:15.510

restart will be needed or at last : http://www.nerdydork.com/update-windows-path-without-rebooting.html

– Robert – 2013-03-12T22:50:09.917

have you tried to use "C:\xampp\php" instead of "C:\xampp\php" not sure if it makes anz difference under windows – Robert – 2013-03-12T22:51:43.640

Ugh, Windows was a long time ago here... perhaps the ending slash is frowned upon? – Wrikken – 2013-03-12T22:56:11.460

Tried id with both the ending slash and without it. Restarted it afterwards to be sure. Same result. This is getting really frustrating. – None – 2013-03-12T23:05:59.640

1Try replacing the path with only the xampp directory. You can do this in the command shell so there's no need to trash your computer's environment or restart. I assume you are trying to run php from the shell rather than the windows 'run' dialog. This might seem like a weird thing to ask, but does it work if you use an explict path: c:\xampp\php\php.exe -v? – paddy – 2013-03-13T03:31:14.833

Ending slash is not a problem with Win7 at least (by default PATH contains C:\Windows\System32\WindowsPowerShell\v1.0\), and a restart is most definitely not required! Only the command prompt window needs to be closed and reopened for the changes to take effect. – Karan – 2013-03-13T04:02:24.500

@paddy: yes, that displays the php install info. But isn't the environment variable's purpose to allow me using 'php' command anywhere in cmd ? – Zubzob – 2013-03-13T09:05:47.470

@zubzob You only answered the least interesting part of my comment. Can you comment on the rest? We're trying to work out what's going on because there's not enough information in your question, or even your comments. My suggestions are not solutions - they are an attempt to isolate the issue. You need to state whether any assumptions we have made are true or false. – paddy – 2013-03-13T21:57:29.130

Answers

5

It works now. The problem was that extra slash at the end (in the PATH environment variable).

I tried with:

C:\Program Files\TortoiseGit\bin;C:\xampp\php\

but it didn't work, then with

C:\Program Files\TortoiseGit\bin; C:\xampp\php

but it didn't work also (notice the extra space before 'C:..').

Eventually,

C:\Program Files\TortoiseGit\bin;C:\xampp\php

did the trick.

Zubzob

Posted 2013-03-12T22:26:46.887

Reputation: 191

@Enke try adding full path C:\xampp\php\php.exe, This could be the problem/ – PHP Mentor – 2015-11-20T16:40:42.700

For me, the "" did the trick, thanks – zhihong – 2018-05-31T15:57:50.037

Still doesn't work for me :( Any other tips? – Enke – 2013-09-17T14:17:21.840