简体   繁体   中英

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?

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):

在此处输入图片说明

When you've clicked on "Edit...", you will get a window with a list of a lot of folder paths like this:

在此处输入图片说明

In that list, locate the one that says C:\\wamp\\bin\\php\\php5.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:\\wamp\\bin\\php\\php7.3.1 (You need to specify a version to PHP that is installed, to see which ones are installed, go to the folder C:\\wamp\\bin\\php 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM