I'm getting an error in wamp about PHP path [duplicate]

给你一囗甜甜゛ 提交于 2019-12-02 03:46:24

WAMPServer does not set the PATH to contain a reference to it's potentially multiple versions of PHP and warns you with the error above that there is a potentially confusing situation on your system if it finds that someone has.

The confusion being that when you run the PHP CLI (Command Line Interface) you will be running the version of PHP referenced in the PATH environment variable. Remember this is only affecting the PHP CLI and not the version of PHP that runs with Apache!


Ok so why is it on the PATH anyway?

  1. If people have attempted to install Apache and PHP manually the install of a Windows Standalone PHP will add the folder containing that version of PHP to the PATH.

  2. You may have followed some bad advice and added a version of WAMPServers own PHP versions to the PATH.


What you should do to remove this error

All you need to do is remove ANY reference to ANY folder that contain a PHP executable from your Windows PATH environment variable.

Look at System Properties Heres how to get to those

So how do you run the PHP CLI for any version of PHP installed in WAMPServer

Here is How I do it, the batch file also includes using Composer and even PEAR is you want to. Amend that to suite you situation.

I fixed it on my own.

I unistalled wamp, deleted the php path (like it says to do on the question I linked above), installed wamp again and then added back the php path (I don't think you have to do this last step, but I did it anyway. It was there, there might be a reason why? edit: it's there because composer needs it).

At first it still wasn't working. I had visual code opened when I did this because I was trying to roll back some migrations I had made before this error, but it was giving me another error (php command not found, or something like that), so I closed visual code, opened it again and it was working. edit: again, composer. I guess because I hadn't closed it, it didn't recognised I had added it back, but this error was because of composer

I still don't know what caused this error, since it was working the last time I checked, with no errors and I didn't change anything, but at least it's fixed.

I don't know if this was the best solution, but I hope it can help someone who is in the same situation as me!

Edit: I know wamp doesn't need the path, but from what I've read and from this experience, composer does.

Wampserver decries it as error. But it's clearly more of a bug.

  • It's just a warning, that you can (and probably should) disable.

  • Wampserver insisting on managing the available PHP versions might be the proper thing to do from their perspective. It shouldn't prevent you from utilizing proper OS lookup features and having a shortcut to PHP CLI however.

  • The message itself, btw

    […]
    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.

    is pretty vague as to how exactly it is "detrimental". Wether Wampserver uses mod_php or FPM shouldn't be affected by a PATH setting. It would be an issue with old-school CGI setups (but nobody is doing that anymore).

    It's kinda bonkers that the message first claims that the environment variable is not used and required, but then goes off to make it sound harmful (without mentioning the concrete conflict).

  • Alternatively you can of course set up the recommended batch wrapper, and remove the versioned folder from your system environment PATH.

See also: http://forum.wampserver.com/read.php?2,151286,151424#msg-151425

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!