I am trying to install a library https://github.com/thephpleague/csv but getting following errors i.e

'This package requires php >= 5.5.9 but your php version <5.4.45> does not satisfy that requirement.'

My current PHP version is 5.6.30 but for some reason composer is showing <5.4.45> which is strange.

I am using ACQUIA DEV DESKTOP on WINDOWS and can switch between PHP versions easily and can check PHP version either by a) dpm(phpinfo()); or b) drush php which is showing same version as set in ACQUIA DEV DESKTOP.

This leads to an issue linked with the composer as it's reading a wrong PHP version.

Steps I have followed to install this library i.e

Copied composer.phar file from 'DevDesktop/tools' folder onto my Drupal project root and then via drush used 'composer require league/csv' which gives me this error ....

'This package requires php >= 5.5.9 but your php version <5.4.45> does not satisfy that requirement.'

I have checked online resources for the similar errors but none of the solution out there matches my situation hence posting this question.

Thanks in advance.

Comments

webdevfreak’s picture

Not sure if this is linked to the issue but I have noticed 'DevDesktop\tools\drush.bat' have first line i.e

IF "%PHP_ID%"=="" (SET PHP_ID=php5_5)

which I changed to

IF "%PHP_ID%"=="" (SET PHP_ID=php5_6)

Stack stop/start and tried to download 'composer require lease/csv' but no change (same results).

webdevfreak’s picture

Found a solution for this error and wanted to share so as it helps anyone else having same problem and possibly improve the solution as it seems to be a quick fix while it should be a universal fix :)

If you install Acquia DevDesktop software, composer comes with this by default.

From Acquia DevDesktop software, we can easily switch between php versions and can also set a default php version but that was not helpful when I try to download library via composer which kept on reading version 5.4.

As Acquia DevDesktop supports different PHP versions i.e 5.3, 5.4, 5.5, 5.6, 7. By default composer was reading php version 5.4 and I still need to find the file which needs to be modified so as default php version can be changed for composer.

In my case what I did was...

Go to Program Files > DevDesktop > tools folder.

There are 4 files having different extensions but same name i.e 'composer'. Remove these all files will remove composer from your system.

Download composer.exe from https://getcomposer.org/ and give it a target folder i.e 'Program Files > DevDesktop > php5_6' and install.

Once installed, now go to your project and by using command prompt or drush console, type 'composer require league/csv' which should download all files in your projects 'vendor' folder.

Bahson’s picture

This saved me alot of headache.. thanks for sharing

ugintl’s picture

Is there any way to switch php version when using composer? I am trying to install markaspot distribution using this command

composer create-project markaspot/mark-a-spot project-dir --stability dev

It gives me error that it requires version 7 and I am using 5.6

webdevfreak’s picture

Here is the solution to switch between PHP versions. 

Just to remind this applies to ACQUIA DEVDESKTOP which has several PHP versions and by using following command, you can easily switch and it works perfectly fine for me i.e

"C:\Program Files (x86)\DevDesktop\php7_1\php" composer.phar update

Path in double quotes is path to your DevDesktop folder on the hard drive.

barbarae’s picture

Thank you so much for your instructions. I spent over a week scratching my head on this challenge and after following your advice, I am now running Composer for Drupal 8.5.5 under Acquia DevDesktop 2 !

webdevfreak’s picture

I am glad it works for you :)

seagle’s picture

Webdevfreak, thank you so much.

webdevfreak’s picture

I am glad it works for you :)