Wamp 3.1.3 Windows Environment PATH conflict
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.
MJ Khan
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Updated on September 12, 2022Comments
-
MJ Khan over 1 year
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 almost 6 years@RiggsFolly .. How come this is duplicate of that thread???
-
RiggsFolly almost 6 yearsBecause 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
-
MJ Khan almost 6 years@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.
-
RiggsFolly almost 6 yearsThe 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
-
MJ Khan almost 6 yearsWell, 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??
-