3

I just installed Wamp 3.1.3, and then installed composer.

The composer added the path to php.exe to windows environment variables. But now Wamp shows error in context menu , that when clicked shows this message:

There is an error.

There is Wampserver path (c:/wamp64) into Windows PATH environnement variable: (C:\wamp64\bin\php\php7.2.4)

It seems that a PHP installation is declared in the environment variable PATH C:\wamp64\bin\php\php7.2.4

Wampserver does not use, modify or require the PATH environment variable. Using a PATH on Wampserver or PHP version is detrimental to the proper functioning of Wampserver.

Now if I remove the path, wamp is happy, but composer would complain that php is not recognized program, and otherwise composer works but wamp complains to remove the path.

Any workaround?

MJ Khan
  • 1,696
  • 3
  • 21
  • 36
  • @RiggsFolly .. How come this is duplicate of that thread??? – MJ Khan May 24 '18 at 05:13
  • Because you should not add anything of WAMPServer to the PATH permanantly. That shows a way to create a batch file you can run at the command prompt that will temporarily, for the life of a command window, add any of the versions of PHP you may have installed to the PATH so you can find PHP CLI for the command prompt – RiggsFolly May 24 '18 at 10:24
  • 1
    @RiggsFolly You are talking about solution. I am asking about the similarity in both questions. The thread you marked is about "How to Run PHP from CLI", and my question is "How can I tackle the conflict between Wamp and Composer"... That is like apples and oranges. Both are sweet doesn't mean both are same. – MJ Khan May 25 '18 at 00:33
  • The idea is that you dont add anything to the PATH permanantly. You write a simple batch file to add the php folder to the path while you are using the command line. Therefore WAMPServer is happy, and you can still run composer from the command line when you want to, or you could use @emix solution – RiggsFolly May 25 '18 at 08:49
  • Well, the answer/solution comes after question, and not before. So now I know the solution provided by emix. But do you think I could know that before posting my question?? – MJ Khan May 25 '18 at 09:07

1 Answers1

6

Install the Composer manually:

Create bat script called composer.bat inside any directory within the PATH so it's system wide containing:

@C:\your\absolute\path\to\php.exe "%~dp0composer.phar" %*

Next time you change PHP simply update the path. Or you can have multiple scripts like composer-php6, composer-php7 etc. calling multiple php versions. Just remember to put the composer.phar alongside your batch script.

No need to update the PATH at all. Good luck.

Mike Doe
  • 16,349
  • 11
  • 65
  • 88