I am using XAMP for magento2. I am not able to run commands and getting error:

php is not recognized as an internal or external command, operable program or batch file

I try these commands: C:\xampp\htdocs\magento2>php bin/magento indexer:reindex, php\bin\magento indexer:reindex

  • Check my response. – Jai Jul 24 '17 at 12:02
  • You can directly run php commands from shell provided with xampp.You will have to navigate to magento root to run magento commands though. – Vivek Kumar Jul 24 '17 at 12:43

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

Example Case for you:

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. Re-indexing:   
    i. Go on to D:
    ii. D:\php\php>php D:\php\htdocs\MG\m212\bin\magento indexer:reindex   


 Installed Xampp_root/php>php   'Path_to_project'

It will work for you.


  1. Go to php installation: cd c:\xampp\php\
  2. After that run: php.exe C:\xampp\htdocs\magento2\bin\magento indexer:reindex
| improve this answer | |
  • i didn't get u jai – user56915 Jul 24 '17 at 12:20
  • Check update answer and try @pawan's respone too. – Jai Jul 24 '17 at 12:36
  • ,so each time i run those type of codes i have to add "php.exe C:\xampp\htdocs\magento2\bin\" ad prefix isn't it – user56915 Jul 24 '17 at 12:57
  • Glad to know that it worked. Good luck – Jai Jul 24 '17 at 14:54

Make sure your PHP path is added to your windows system's environment variable. After that you may able to run commands successfully.

Here is tutorial Add PHP to Your Windows Path Variable will help you

Or you can try below command

C:\xampp\php\php.exe C:\xampp\htdocs\magento2\bin\magento indexer:reindex

| improve this answer | |

Try This Command

D:\xampp7.2\php\php.exe D:\xampp7.2\htdocs\m232\bin\magento indexer:reindex

Use In Batch File

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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