PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, December 31, 2021

[FIXED] When executing Composer commands error "'php' is not recognized as an internal or external command, operable program or batch file"

 December 31, 2021     composer-php, laravel, path, php     No comments   

Issue

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.


Solution

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('https://getcomposer.org/installer', '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


Answered By - Ali Sharifineyestani
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing