Magento – Running magento2 commands in Windows XAMPP

magento2

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

Best Answer

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   

On XAMPP

 Installed Xampp_root/php>php   'Path_to_project'

It will work for you.

EDIT:

  1. Go to php installation: cd c:\xampp\php\
  2. After that run: php.exe C:\xampp\htdocs\magento2\bin\magento indexer:reindex