Question

[Solved] PHP is not recognized as an internal or external command in command prompt

I got the following error when I run a command with php

C:xampphtdocs>php
'php' is not recognized as an internal or external command,
operable program or batch file.

I don’t get any error when I run the command with php in following path:

C:xamppphp>php  //do not got error here

Why I get this error?

‘php’ is not recognized as an internal or external command, operable program or batch file.

Solution #1:

Add C:xamppphp to your PATH environment variable.(My Computer->properties -> Advanced system setting-> Environment Variables->edit path)

Then close your command prompt and restart again.

Note: It’s very important to close your command prompt and restart again otherwise changes will not be reflected.

Respondent: Alive to Die

Solution #2:

You need to Go to My Computer->properties -> Advanced system setting

Now click on Environment Variables..

enter image description here

Add ;C:xamppphp in path variable value

enter image description here

Now restart command prompt DONE!

Note: Make sure you run CMD via run as administrator

Respondent: Prince Patel

Solution #3:

You just need to a add the path of your PHP file. In case you are using wamp or have not installed it on the C drive.

The picture shows how to find the path

Respondent: Progga Ilma

Solution #4:

Set "C:xamppphp" in your PATH Environment Variable. Then restart CMD prompt.

Respondent: Vikas

Solution #5:

Is your path correctly configured?

In Windows, you can do that as described here:

http://www.computerhope.com/issues/ch000549.htm

Respondent: user5093637

Solution #6:

You need to add C:xamppphp to your PATH Environment Variable, Only after then you would be able to execute php command line from outside php_home.

Respondent: Raja

Solution #7:

I also got the following error when I run a command with PHP, I did the solution like that:

  1. From the desktop, right-click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable window, Add C:xamppphp to your PATH Environment Variable.

Very important note: restart command prompt

Respondent: Udhav Sarvaiya

Solution #8:

enter image description here
enter image description here

Here what I DO on MY PC I install all software that i usually used in G: partian not C:
if my operating system is fall (win 10) , Do not need to reinstall them again and lost time , Then How windows work it update PATH automatic if you install any new programe or pice of softwore ,

SO

I must update PATH like these HERE! all my software i usually used

%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;G:HashiCorpVagrantbin;G:xamppphp;G:xamppmysqlbin;G:Program Files (x86)herokubin;G:Program Files (x86)Gitbin;G:Program Files (x86)composer;G:Program Files (x86)nodejs;G:Program Files (x86)Sublime Text 3;G:Program Files (x86)Microsoft VS Codebin;G:Program Files (x86)cygwin64bin

enter image description here

Respondent: Abubakr Elghazawy

Solution #9:

Extra info:

If you are using PhpStorm as IDE, after updating the path variable you need to restart PhpStorm so that it takes effect.

Restarting terminal window was not enough for me. (PhpStorm 2020.3.2)

Respondent: Adem Tepe

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy