PHP is not recognized as an internal or external command in command prompt
It sounds like you are trying to run the PHP command from the command prompt, but it is not recognized as a valid command.
It sounds like you are trying to run the PHP command from the command prompt, but it is not recognized as a valid command. There are a few possible reasons for this:
- PHP is not installed on your system. To use the PHP command from the command prompt, you will need to have PHP installed on your machine. You can download and install PHP from the official PHP website (https://www.php.net/downloads.php).
- The PHP executable is not in your system's PATH. The PATH is a list of directories that the command prompt searches for executables. If the PHP executable is not in a directory listed in the PATH, you will need to add it. On Windows, open the Start menu, search for "Environment Variables", select "Edit the system environment variables", click "Environment Variables...", find
Pathunder System variables, click "Edit", then "New", and paste the full path to your PHP installation directory (e.g.,C:\php). Click "OK" on all dialogs and restart your command prompt. - You are using the wrong command. If you are trying to run a PHP script, you should use the
phpcommand followed by the name of the script you want to run.
Verification & Usage After installing or updating your PATH, verify the setup by running:
php -vIf PHP is installed correctly, this will display the version. To run a script, use:
php script.phpNote: These steps apply specifically to Windows Command Prompt. For PowerShell, the process is similar. On macOS or Linux, ensure PHP is installed via your package manager (e.g., brew install php or sudo apt install php) and that the binary is in your $PATH.
We hope this helps! Let us know if you have any other questions.