2

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

2
  • Check my response. Commented Jul 24, 2017 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. Commented Jul 24, 2017 at 12:43

3 Answers 3

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

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
5
  • i didn't get u jai Commented Jul 24, 2017 at 12:20
  • Check update answer and try @pawan's respone too. Commented Jul 24, 2017 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 Commented Jul 24, 2017 at 12:57
  • Glad to know that it worked. Good luck Commented Jul 24, 2017 at 14:54
  • if you want to use it in this way use this ./../../php/php.exe bin/magento. But this also not help to reduce time for executing command Commented Jul 13, 2021 at 21:15
1

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

0

Try This Command

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


Use In Batch File

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.