61

I try to install Laravel 5.1 on a host which only has PHP 5.5.6. While I asked the customer to upgrade, this might be not possible/feasible.

So I am getting:

- This package requires php >=5.5.9 but your PHP version (5.5.6)
   does not satisfy that requirement.

on composer.phar install.

Is there a way to do a composer install which ignores this dependency?

I think it should be safe, as there are only bug-fixes from 5.5.6 to 5.5.9.

Alex
  • 32,506
  • 16
  • 106
  • 171
  • 1
    The Laravel project unfortunately decided that they declare their 5.1 release compatible to the oldest available PHP version they can test with on TravisCI, which is 5.5.9. On the one hand this is a reasonable choice. On the other hand it is an unnecessary hurdle for people running on older releases of the 5.5 PHP branch, because there are no backwards incompatible changes in PHP 5.5 before 5.5.9 - the code will run. The problem with `--ignore-platform-req` is that it affects ALL packages, you might get packages that only run with PHP 5.6. – Sven Sep 29 '15 at 22:14
  • See also: [Reference - Composer error “Your PHP version does not satisfy requirements” after upgrading PHP](https://stackoverflow.com/q/66368196/157957). – IMSoP Feb 25 '21 at 13:57

8 Answers8

159

You can use --ignore-platform-reqs option for composer commands like install, update etc.

--ignore-platform-reqs: ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these. See also the platform config option.

https://getcomposer.org/doc/03-cli.md

So you can try with

composer install --ignore-platform-reqs
MilanG
  • 6,994
  • 2
  • 35
  • 64
Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64
  • Is there also a finer grained method which ignores only the PHP version? Or I even can require 5.5.6 instead of 5.5.9 – Alex Sep 29 '15 at 08:20
  • I don't think there's such a thing. At least I can't find it. – Jakub Matczak Sep 29 '15 at 08:23
  • Found a way. Was directly there in the docs. But works only for subpackages. See my answer. – Alex Sep 29 '15 at 09:42
  • Check [this question](https://stackoverflow.com/q/47849825/1883256) as well – Pathros Jan 18 '21 at 23:33
  • "+1" and More helpful this tutorial: [How to solve Root composer.json requires PHP ^7.3 but your PHP version (8.0.0) does not satisfy that requirement](https://devnote.in/how-to-solve-root-composer-json-requires-php-7-3-but-your-php-version-8-0-0-does-not-satisfy-that-requirement/). – Fefar Ravi Feb 26 '22 at 08:29
45

The error message indicates a requirement from the main composer.json. The version requirement can be just adapted:

"require": {
    "php": ">=5.5",

After changing the version like this I get:

  Problem 1
    - Installation request for classpreloader/classpreloader 2.0.0 -> satisfiable by classpreloader/classpreloader[2.0.0].
    - classpreloader/classpreloader 2.0.0 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 2
    - Installation request for laravel/framework v5.1.17 -> satisfiable by laravel/framework[v5.1.17].
    - laravel/framework v5.1.17 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 3
    - Installation request for laravelcollective/html v5.1.6 -> satisfiable by laravelcollective/html[v5.1.6].
    - laravelcollective/html v5.1.6 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 4
    - laravel/framework v5.1.17 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
    - jenssegers/agent v2.1.7 requires illuminate/support ~4.0|~5.0 -> satisfiable by laravel/framework[v5.1.17].
    - Installation request for jenssegers/agent v2.1.7 -> satisfiable by jenssegers/agent[v2.1.7].

Using the following snippet in composer.json, a php version can be simulated

[...]
"config": {
    "preferred-install": "dist",
    "platform": {
        "php": "5.5.9"
    }
}

Doc: https://getcomposer.org/doc/06-config.md#platform

platform

Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {"php": "5.4", "ext-something": "4.0"}.

Don't forget to run a composer.phar update after this

Alex
  • 32,506
  • 16
  • 106
  • 171
  • I went through `platform` section but didn't read it carefully. So simple :) I've added doc quote to your answer. – Jakub Matczak Sep 29 '15 at 10:08
  • 2
    The simulation of the platform package mentioned here also helps if your base PHP is running a different version to the version which the code is running on. For example, one of my servers running Plesk has a base PHP version of 5.3.x, the code for the virtual site is running on 5.4.x. Without this, a centrally installed composer only picks up on the base version, so can create problems when trying to use a package dependent on a different PHP version – Phil Young Jul 14 '16 at 10:41
  • Is there a way to do this from CLI? Something like `composer install --config platform.php 5.3.3` – Starx Sep 19 '16 at 08:47
  • 1
    @Starx Why not use `--ignore-platform-reqs` ? – Alex Sep 20 '16 at 08:18
  • @Alex, Because I need to specify an older version of PHP in one of the machines. – Starx Sep 20 '16 at 09:31
  • 1
    @Starx: Yes, `composer config platform.php 5.6`. – deltab Oct 06 '17 at 12:57
15

I got the same issue which resolved with following command :

composer config platform.php 7.2.22 

*** you can replace PHP version according to yours.

prashant
  • 1,012
  • 12
  • 21
  • Are you sure this helps? If the package asks for a specific PHP version, there might be a good reason not to ignore this – Nico Haase Dec 16 '19 at 09:02
  • @NicoHaase Yes defiantly... I've tested this and it works for me that's why I've shared here if it helps anyone else. – prashant Dec 16 '19 at 10:40
  • @NicoHaase Also I'm not asking to ignore php version, my issue was there was incorrect php version mentioned in my composer file which I've corrected and composer install worked. – prashant Dec 16 '19 at 10:42
  • Thank you. This might be very useful for those on Mac Catalina that updates php right away. – Robert Saylor May 04 '20 at 16:02
  • i think the good way is : `composer install --ignore-platform-reqs ` this commands save my life.. haha :v – Fauzi Ferdiansyah Nov 03 '21 at 14:57
9

Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement.

composer install --ignore-platform-reqs

Bira
  • 4,531
  • 2
  • 27
  • 42
  • 1
    Thanks, I couldn't use the other answers with the recommended-project `composer --ignore-platform-reqs create-project drupal/recommended-project:8.9.20 project-name` but this answer worked. – paulguy Dec 12 '21 at 21:23
3

change your php version like

"require": {
    "php": "^7.3|^8.0",
    .....
},

or like

"require": {
    "php": ">=7.3",
    .....
},
ANIK ISLAM SHOJIB
  • 3,002
  • 1
  • 27
  • 36
2

running a version independent command solves this error composer install --ignore-platform-reqs

P.Githinji
  • 1,459
  • 11
  • 5
2

Just add these lines in composer.json file

  "config": {
    "platform": {
      "php": "5.5.9"
    }
  },

Then run command,

composer update or install
Faisal Khan
  • 91
  • 2
  • 9
1

change php version in composer.json

Delete composer.lock

RUN: composer install

It works for me