Skip to content
Advertisement

How can I fix which version of Windows PHP is being used for the CLI?

I have WAMPServer 3.0.6 with PHP 7.0.10 Installed. I use Git Bash to use server side cli for my projects, mainly Laravel. There’s a package that needs PHP 7.0 to work and even tought my WAMP Server is using PHP 7 to run it can’t identify the correct version of PHP in the Command Line.

When I use php -v I get

PHP 5.6.25 (cli) (built: Aug 18 2016 11:39:15)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

How can I make CLI to use 7.0.10?

Advertisement

Answer

You can edit the Windows Path variable for PHP. To do so, right click on the Computer folder and choose “properties”. That should open a Control Panel window. In that window, click on “Advanced system settings” in the panel on the left, and then click on the “Environment Variables” button. Then select “Path” and click on “Edit…”. Here is a screenshot of these steps (sorry it’s in Swedish but the buttons should be in the same place in any language):

enter image description here

When you’ve clicked on “Edit…”, you will get a window with a list of a lot of folder paths like this:

enter image description here

In that list, locate the one that says C:wampbinphpphp5.6.25 (or whatever version of PHP it uses by default), edit it by double-clicking on it, and replace it with whatever PHP version you want to use, for example C:wampbinphpphp7.3.1 (You need to specify a version to PHP that is installed, to see which ones are installed, go to the folder C:wampbinphp in Windows Explorer, each version of PHP that is installed has its own folder in there). When you’re done editing the path variable, click on OK in all windows you opened and you should be done. If you had the command prompt open while you were doing this, you may need to restart the command prompt for it to take effect.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement