Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch php version when running composer? [duplicate]

I have composer installed on windows 8.1. I use it to download drupal distributions and modules. I have also installed acquia dev desktop. As you know that dev desktop comes with different versions of php and it has separate folders for it. I have setup composer to use php 5.6. How can I make it use php 7?

Should I uninstall composer and install again or what?

like image 669
Umair Avatar asked Mar 08 '18 17:03

Umair


3 Answers

IF you have multiple php version installed in your system

you can run composer with different versions like

In linux

PHP

    usr/local/php usr/bin/composer install

for PHP 7.1

usr/local/php7.1 /usr/local/composer install

actually the idea is which version you wants to run get its bin path and then run the composer.

In Windows.

path/to/php.exe composer install

Hope this helps

like image 108
Romantic Dev Avatar answered Oct 19 '22 18:10

Romantic Dev


If you just want to ignore the php version dependency then you can use this -

--ignore-platform-reqs

Example:

composer require symfony/css-selector --ignore-platform-reqs

This way you don't have to edit Environment variables(windows os) or using any full path of php etc. This very useful when I use different php lib from github which requires different php version set in my windows Environment variables though I have all PHP versions in my WAMP server so it will not be any problem running those lib after installing.

like image 43
Codextent Avatar answered Oct 19 '22 17:10

Codextent


In my case worked with this:

ea-php72 /opt/cpanel/composer/bin/composer update
like image 34
Erich García Avatar answered Oct 19 '22 18:10

Erich García