Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change PHP version used by composer

I want to use another php version on my machine than the one already installed using WAMP (2 PHP version installed).

  • The composer installed uses PHP 5.6
  • A new project requires PHP7.0.

Whenever I choose PHP 7 from the control panel of WAMP and then run php -v it still printing PHP5.6 (CLI)... instead of PHP7.

How can I use PHP7 without reinstalling the composer again?

like image 834
Jie Avatar asked Oct 28 '17 04:10

Jie


People also ask

Which PHP version does composer use?

So, while the 7.2 version is used to run Composer, the scripts called by Composer use the default command.

Can composer update PHP?

It also makes maintaining the latest versions of all required libraries easier because you can simply run composer update to get the latest compatible packages.


1 Answers

You can change php version of composer without uninstalling it, follow these steps :

  1. Search for system environment variables in cortana.
  2. Click on the button "Environment variables".
  3. Under "System variables" select path and click on edit, you will see one entry like this "C:\wamp\bin\php\php5.6.13".
  4. Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here php7.1.9 is folder name.
  5. Replace php5.6.13 with bin7.1.9, it will look like these "C:\wamp\bin\php\php7.1.9", just click ok on all the boxes.
  6. You are done.
  7. To verify, first close all the cmd windows, than open cmd and type php -v, press enter and you should see php7.1.9.
  8. If you don't see change in php version than just restart your pc and run php -v again in cmd , it will work.
like image 142
geeky Avatar answered Sep 29 '22 14:09

geeky