Home Server TweakingHow to Fix “PHP Is Not Recognized as an Internal or External Command” in Windows

How to Fix “PHP Is Not Recognized as an Internal or External Command” in Windows

by SupportPRO Admin
photo of a developer(Black shadow) using Windows Command Prompt on a desktop computer, environment variables window open on screen

 If you see this error in Command Prompt:

'php' is not recognized as an internal or external command

it means Windows cannot find the PHP executable file.

This happens when the PHP installation directory is not added to the system PATH environment variable.

Let’s understand why this happens and how to fix it properly.

Why This Error Occurs

Windows uses a special environment variable called PATH to locate executable files when you run commands in Command Prompt.

If PHP was:

  • Installed manually
  • Extracted from a ZIP archive
  • Installed without automatic configuration

then its installation directory may not have been added to PATH.

When that happens, Windows doesn’t know where php.exe is located — and the command fails.

What Is the PATH Variable?

The PATH variable is a list of directories that Windows searches when you type a command.

For example:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem

If C:\php is not included in this list, Windows will not find php.exe.

Solution: Add PHP to the PATH Variable

You need to add your PHP installation folder (for example, C:\php) to the system PATH.

Example

Current PATH

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem;C:\Program Files\Intel\DMIX

Corrected PATH (PHP Added)

C:\php;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem;C:\Program Files\Intel\DMIX

Placing C:\php at the beginning ensures Windows checks that directory first.

Step-by-Step Instructions (Windows 10 / 11)

Step 1: Open System Properties

Press:

Win + R

Type:

sysdm.cpl

Press Enter.

Step 2: Go to Advanced Tab

Click AdvancedEnvironment Variables

Step 3: Edit System PATH

Under System Variables:

  1. Find Path
  2. Click Edit
  3. Click New
  4. Add:
C:\php

(Replace with your actual PHP installation directory)

Step 4: Save Changes

Click OK on all windows.

Step 5: Restart Command Prompt

Close and reopen Command Prompt.

Verify the Fix

Run:

php -v

If configured correctly, you will see your installed PHP version instead of an error.

How to Confirm PHP Location

If you’re unsure where PHP is installed:

  • Check where you extracted it
  • Look inside C:\Program Files
  • Use File Explorer search for php.exe

Common Mistakes to Avoid

Adding the wrong folder

Make sure you add the folder containing php.exe, not the file itself.

Correct:

C:\php

Wrong:

C:\php\php.exe

Not Restarting Command Prompt

Environment changes require a new terminal session.

Multiple PHP Versions in PATH

If you have multiple PHP versions:

  • The first one listed in PATH takes priority
  • Remove unused versions
  • Reorder paths carefully

Advanced Tip: Check Current PATH via Command Line

You can see your current PATH using:

echo %PATH%

This helps identify duplicates or incorrect entries.

FAQ

Why does PHP work in XAMPP but not in Command Prompt?

Because XAMPP runs PHP internally and does not require a global PATH entry. For system-wide access, PHP must be added to PATH.

Do I need to restart my computer?

No. Restarting Command Prompt is usually enough.

Can this issue happen on Windows Server?

Yes. The solution is the same – update the system PATH variable.

In case of any doubt, contact SupportPro.

Partner with SupportPRO for 24/7 proactive cloud support that keeps your business secure, scalable, and ahead of the curve.

Contact Us today!
guy server checkup

You may also like

Leave a Comment