I am getting error in command line in window. "command is not recognized as an internal and external command. operable program or batch file". this error occurs when i run any command.

  • Check my answer and @parth's answer. Let me know if it didnt work.
    – Jarnail S
    Jun 15, 2017 at 6:18

3 Answers 3


You can run php pages using php.exe create some php file with php code and in the cmd write:

[PATH to php.ext]\php.exe [path_to_file]\file.php

you can also add path of php.exe in system PATH environment variable so you can use PHP as command from any directory in windows.

Example Case:

  1. My XAMPP is installed on D:\php\ and php.exe resides in D:\php\php and Magento folder is here D:\php\htdocs\MG\m212 ( http://localhost/MG/m212/)
  2. Go on to D drive.
  3. D:\php\php>php D:\php\htdocs\MG\m212\bin\magento indexer:reindex


 Installed Xampp_root/php>php   'Path_to_project'

On WAMPP: The PHP CLI as its called ( php for the Command Line Interface ) is called php.exe It lives in c:\wamp\bin\php\php5.x.y\php.exe ( where x and y are the version numbers of php that you have installed )


You have to go to the php folder where xampp is installed and then run the commands by passing the full path to


For example, I have php folder under F: drive. So, I will first go to F:/xampp/php and then will run the commands. e.g.

php F:\xampp\htdocs\magento-2\bin\magento setup:upgrade


Open CLI from Xampp and go inside project. Assumed your project and xampp on D: Drive:

Navigate inside project like: cd D:\xampp\htdocs\Magento2

CLI Path will be like: D:\xampp\htdocs\Magento2
php bin\magento setup:upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.