Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 722
Jorge Peña Avatar asked May 10 '17 19:05

Jorge Peña


People also ask

What version of PHP do I have Windows command line?

Typing php -v now shows the PHP version installed on your Windows system.

What version of PHP Am I running terminal?

Open a bash shell terminal and use the command “php –version” or “php -v” to get the version of PHP installed on the system.

What is PHP CLI version?

PHP's Command Line Interface (CLI) allows you to execute PHP scripts when logged in to your server through SSH. ServerPilot installs multiple versions of PHP on your server so there are multiple PHP executables available to run.


1 Answers

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

On Windows 11 the first window looks different, there you can find "Advanced system settings" under "Device specifications" as shown below. The other windows look exactly the same.

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:\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.

like image 67
Donald Duck Avatar answered Oct 06 '22 00:10

Donald Duck