When Executing Composer Commands Error "'php' Is Not Recognized As An Internal Or External Command, Operable Program Or Batch File"

- 1 answer

So I've been trying to install Laravel with Composer for about a week and a half now using windows 10 and wamp and even Homestead at one point. Every time I execute the "composer create-project --prefer-dist laravel/laravel demo" or anything else that Composer uses PHP to be executed, the error " 'php' is not recognized as an internal or external command, operable program or batch file" appears.

When searching for this problem all solutions point to the Path variable and adding a PHP path to it, but that's not the problem. Executing PHP commands normally without Composer works 100% of the time with 0 errors and the PHP path already exists. Only when using Composer does this error appear.

Can someone please help me find out how to solve this problem? It's an emergency. I'm about to graduate college and I need to use Laravel to make my end of Semester project. I'd gladly share any information to those who want to help me solve this problem.



Add C:\xampp\php to your PATH environment variable. Then close your command prompt and restart again.

Then Install Composer using the Command-line

php -r "copy('', 'composer- setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Test the install

php composer.phar