[Fixed] PHP is not recognized as an internal or external command

[Fixed] PHP is not recognized as an internal or external command

The PHP is not recognized as an internal or external command, operable program or batch file error typically occurs when the PHP executable path cannot be added in the system’s PATH environment variable. In this tutorial, we will show you two approaches on how to fix this error.

Here are two possible solutions that you can follow to fix this error.

  • Solution 1: Set PHP path to system environment variable
  • Solution 2: Uninstall and Reinstall xampp PHP

Solution 1: Set PHP path to system environment variable

If you already have PHP installed in your system and you get the error like PHP is not recognized as an internal or external command, operable program or batch file, then Windows XAMPP

Then, you can easily fix this by adding the php executable path to the system’s PATH environment variable. Here are steps to fix this:

  • 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:

Step 2 – Environment Setting

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

Step 3 – Edit System Environment Variable Path

Edit system environment variable path; as shown below picture:

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

Solution 2: Uninstall and Reinstall xampp PHP

Still get the same error after using first Solution. So, you need to uninstall xampp php from your system and re-install xampp php.

Recommended Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *