magento 2 'php' is not recognized as an internal or external command, operable program or batch file.

When running the following command in magento 2 "php bin/magento setup:static-content:deploy"

Magento 2 while running cli commands on command prompt we sometimes getting the following error in windows 10 machine or windows xp as "'php' is not recognized as an internal or external command, operable program or batch file."


To solve this error we will need to add the php path to the system enviroment variable and we will see how to add the following



In windows 10
 Go To

  Start Menu  > Search for  "Advanced system setting"







Click on " Enviroment Variable"



Add the following value in the path  "C:\xampp\php"

now we will close the command prompt and start it again , and type php , it will begin to work



It will begin to work