Override PHP base dependency in composer

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.


Solution 1:

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:

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:

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:

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

composer install --ignore-platform-reqs