简体   繁体   中英

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.

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

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

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.

运行与版本无关的命令可解决此错误composer install --ignore-platform-reqs

Just add these lines in composer.json file

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

Then run command,

composer update or install

根 composer.json 需要 php ^7.3 但您的 php 版本 (8.0.0) 不满足该要求。

composer install --ignore-platform-reqs

change your php version like

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

or like

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

change php version in composer.json

Delete composer.lock

RUN: composer install

It works for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM