Why Isn’t PHP Recognized As An Internal Or External Command In The Command Prompt?

If you’re getting the "PHP is not recognized as an internal or external command" error in the command prompt, it means that the PHP executable is not added to your system’s PATH variable. The PATH variable contains a list of directories where the operating system looks for executable files.

To fix this issue, you can follow these steps:

  1. Make sure PHP is installed on your system. You can download the latest version of PHP from the official PHP website (https://www.php.net/downloads.php) and follow the installation instructions for your operating system.

  2. Once PHP is installed, find the directory where it is installed. The default installation directory might be something like C:\php or C:\Program Files\PHP.

  3. Open the Start menu, search for "Environment Variables," and click on "Edit the system environment variables" option.

  4. In the System Properties window, click on the "Environment Variables" button at the bottom.

  5. In the "System variables" section, scroll down and find the "Path" variable. Select it and click on the "Edit" button.

  6. In the Edit Environment Variable window, click on the "New" button and enter the path to your PHP installation directory (e.g., C:\php).

  7. Click "OK" to close all the windows.

  8. Now open a new command prompt window and try running PHP commands again. It should recognize the PHP command without showing the error.

If you still encounter any issues, make sure to restart your computer after adding the PHP installation directory to the PATH variable.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!