PHP is not recognized as an internal or external command
Have you ever faced this type of error while running PHP command from command prompt? Some PHP files like cron job and socket server, we need to run them from command prompt. Normally this type of error only produce when we use php
command in command prompt without setting up PHP path in system environment variable. Thus, it will throw error like PHP is not recognized as an internal or external command. So in this post, i will show you how to setup PHP path in system environment variable and get rid of this error.
PHP is not recognized as an internal or external command error in windows command prompt.
Before continue, I assume that you have already installed PHP in your windows system. If you haven’t then you can checkout our tutorial on how to install PHP in windows using XAMPP.
Now first of all find out PHP path from your system. For XAMPP server, your installed PHP path is (Drive Name):/xampp/php
[Drive name should be your xampp installed drive]. If you have installed other PHP environment like WAMP or LAMP then, please check PHP path on google for them.
I have installed XAMPP in E:
drive. So my PHP path is E:\xampp\php
.
Now open control panel and search for “System” and click on it.
Now click on “Advanced System Settings“.
Now click on “Environment Variables“.
Now select Path in system variables section and click on Edit button.
Now add PHP path (E:\xampp\php
) after (;) semicolon at last as shown below image and click Ok.
Now lets check if error is fixed or not. If you have already opened command prompt, please close and reopen it. Otherwise changes will not reflect on it. Set XAMPP path (E:/xampp
) in it.
Now run php -v
command to check php version. If everything works fine than you will see version of PHP.
Congratulation you have done it.
I hope that this tutorial helps you. If you have any query regarding this tutorial then please share with me in the comments. I will help you to short it out. Thank you for reading this article.
thanks you .(iran)
You are excellent.
thank you very much Mr. Panchal.
Thank you Mohammad 🙂
Thank you very much!
Nor Stackoverflow neither Cpanel website couldn’t help me with this problem, But you did.
Thank you very much
Thank You Dani
I stucked one day with this issue…..finally i found the issue..that is the semicolon at the end of the path variable…..now it works fine..Thanks a lot bro…..
It perfectly worked. Thank you for your clear solution
Thank You Omid.
Thanks you very much and excellent work. I hope you can support community more than this.
I spent a whole morning trying fixing this problem and it was very helpful.
Cool Thanks 🙂
this is very helpful. Thank you for the info
Thank you :). Keep visting.
Thank you so much for detailed explanation.
sorry
worked your metod
thank you very much
It Works and saved my day……. Thanks