7

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?

Machavity
  • 30,841
  • 27
  • 92
  • 100
Jorge Peña
  • 477
  • 5
  • 12
  • Uninstall 5.6.25? – Alex Howansky May 10 '17 at 19:27
  • 1
    Doesn't work. WAMP always searches for that installation even if you've already specified the use of 7.0.10. WAMP has an option to select the version of PHP you want to use in its UI. The problem is in the Command Line – Jorge Peña May 10 '17 at 19:30
  • See this http://stackoverflow.com/questions/15597067/how-to-run-php-from-windows-command-line/16289254#16289254 – RiggsFolly May 10 '17 at 20:01
  • 2
    Also Make sure you have NOT added ANY folder containing ANY version of PHP to your Windows PATH – RiggsFolly May 10 '17 at 20:03
  • Thx @RiggsFolly . Machavity answer on the other question states that I have to have a php installation on my C:\ path for composer to use that version. Glad to hear another opinion. – Jorge Peña May 10 '17 at 20:05
  • I install Composer into `wamp\composer` then add a bit extra to that batch file to include the Composer folder onto the path and add the environment variables required by Composer. No permanant environment chnages required, and it all disappears when you close the command window – RiggsFolly May 10 '17 at 20:17
  • 4
    It seems not to be a duplicate question. I already have this issue. I solve it by modifiying the path variable by replacing php5.6 with the php7.0 path – Mame Medoune Diop Mar 27 '18 at 11:37
  • @Machavity The other questions are asking about how to run any PHP version from the command line. In this question, the OP knows how to run PHP 5 from the command line (by typing `php` in the command prompt) and is asking how to make that run PHP 7 instead of PHP 5. – Donald Duck Jan 16 '20 at 20:03
  • Why don't use xampp? – Matías Rodríguez Jan 16 '20 at 20:55

1 Answers1

1

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.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99