PHP is not recognized as an internal or external command

[ad_1]

The error message “PHP is not recognized as an internal or external command, operable program or batch file” typically occurs when you try to run a PHP script or command in your command prompt or terminal, but the system cannot find the PHP executable in the system’s PATH.

Ezoic

php is not recognized as an internal or external command, operable program, or batch file; Through this tutorial, you will learn how to set or add PHP environment variables in Windows xampp to fix php is not recognized as an internal or external command, operable program or batch file.

PHP is not recognized as an internal or external command

Steps to set php environment variables windows xampp to fix php is not recognized as an internal or external command, operable program, or batch file:

Ezoic

  • Step 1 – Open Windows Environment Setting
  • Step 2 – Edit Environment Setting
  • Step 3 – Edit System Environment Variable Path
  • Step 4 – Add PHP Path
  • Step 5 – Restart Windows 11|10
  • Step 6 – Open the Command Prompt and Check the PHP Version

Step 1 – Open Windows 11/10 Environment Setting

First of all, visit your system’s bottom search bar and search Environment Variables; as shown below picture:

Ezoic

Step 2 – Environment Setting

Then Click on the environment variable setting; as shown below picture:

Ezoic

Step 3 – Edit System Environment Variable Path

Edit system environment variable path; as shown below picture:

Ezoic

Step 4 – Add PHP Path

Add/set PHP xampp path in environment setting; as shown below picture:

Note that; we have installed xampp in the D directory.

If you are using linux or mac system, to add/set PHP xampp path in environment setting:

  • Open a terminal window.
  • Edit your shell configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.profile) using a text editor (e.g., nano, vim, or gedit).
  • Add the following line to the file, replacing /path/to/php with the actual path where PHP is installed:
    • export PATH=”/path/to/php:$PATH”
  • Save the file and exit the text editor.
  • Run source ~/.bashrc or source ~/.zshrc (or the appropriate file for your shell) to apply the changes to your current terminal session.

Step 5 – Restart Windows 11|10

Restart your Windows 11|10 system.

Step 6 – Open the Command Prompt and Check the PHP Version

After adding PHP to your PATH, open a new terminal or cmd window and type php -v (on Windows) or php --version (on Linux/macOS) to check if PHP is recognized as a command. You should see the PHP version information if PHP is correctly installed and configured.

php -v

Recommended PHP Tutorials

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00