Override PHP base dependency in composer

PhpComposer Php

Php Problem Overview


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.

Php Solutions


Solution 1 - Php

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

Solution 2 - Php

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

Solution 3 - Php

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.

Solution 4 - Php

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

composer install --ignore-platform-reqs

Solution 5 - Php

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

Solution 6 - Php

Just add these lines in composer.json file

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

Then run command,

composer update or install

Solution 7 - Php

change your php version like

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

or like

"require": {
    "php": ">=7.3",
    .....
},

Solution 8 - Php

change php version in composer.json

Delete composer.lock

> RUN: composer install

It works for me

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexView Question on Stackoverflow
Solution 1 - PhpJakub MatczakView Answer on Stackoverflow
Solution 2 - PhpAlexView Answer on Stackoverflow
Solution 3 - PhpprashantView Answer on Stackoverflow
Solution 4 - PhpBiraView Answer on Stackoverflow
Solution 5 - PhpP.GithinjiView Answer on Stackoverflow
Solution 6 - PhpFaisal KhanView Answer on Stackoverflow
Solution 7 - PhpANIK ISLAM SHOJIBView Answer on Stackoverflow
Solution 8 - PhpDebraj GhoshView Answer on Stackoverflow