在编辑器中覆盖 PHP 基本依赖项

2022-08-30 10:06:12

我尝试在只有PHP 5.5.6的主机上安装Laravel 5.1。虽然我要求客户升级,但这可能是不可能的/可行的。

所以我得到:

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

上。composer.phar install

有没有办法进行忽略此依赖关系的作曲家安装?

我认为它应该是安全的,因为只有从5.5.6到5.5.9的错误修复。


答案 1

您可以将选项用于作曲家命令,如 等。--ignore-platform-reqsinstallupdate

--ignore-platform-reqs:忽略 php、hhvm、lib-* 和 ext-* 要求,并强制安装,即使本地计算机不满足这些要求。另请参阅平台配置选项。

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

所以你可以尝试

composer install --ignore-platform-reqs

答案 2

错误消息指示来自主 .版本要求可以随之调整:composer.json

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

像这样更改版本后,我得到:

  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].

使用以下代码片段,可以模拟 php 版本composer.json

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

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

平台

允许您伪造平台包(PHP和扩展),以便您可以模拟生产环境或在配置中定义目标平台。示例:{“php”: “5.4”, “ext-something”: “4.0”}.

不要忘记在此之后运行composer.phar update


推荐