composer install -n --ignore-platform-reqs 不忽略 PHP 扩展

composer install -n --ignore-platform-reqs not ignoring PHP extension

我们有运行 composer install -n --ignore-platform-reqs --no-dev 的循环构建,但这不再忽略平台要求。

这是我在圈子里看到的。 --ignore-platform-reqs 显然不起作用。有什么想法吗?

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for drupal/core 8.6.13 -> satisfiable by drupal/core[8.6.13].
    - drupal/core 8.6.13 requires ext-pdo * -> the requested PHP extension pdo is missing from your system.
  Problem 2
    - typo3/phar-stream-wrapper v2.1.0 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - typo3/phar-stream-wrapper v2.1.0 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - Installation request for typo3/phar-stream-wrapper v2.1.0 -> satisfiable by typo3/phar-stream-wrapper[v2.1.0].

我将回答我自己的问题,以防万一有人在这里绊倒。在我的 composer.json 文件中添加扩展名列表解决了我的问题。这个 --ignore-platform-reqs 没有效果。

 "provide": {
        "ext-fileinfo": "*",
        "ext-pdo": "*",
        "ext-session": "*",
        "ext-iconv": "*",
        "ext-zip": "*"
    }

与其使用 --ignore-platform-reqsprovide hack,不如使用 platform 设置来模拟您的环境 - 它使您可以更好地控制平台要求,并且比 provide(你的包裹并没有真正提供ext-fileinfo):

"config": {
    "platform": {
        "php": "7.2.14",
        "ext-fileinfo": "1.0.5",
        "ext-pdo": "7.2.14",
        "ext-session": "7.2.14",
        "ext-iconv": "7.2.14",
        "ext-zip": "1.15.4"
    }
},

您可以通过在生产环境中调用此命令找到扩展的实际版本(尽管您可能可以为扩展版本添加任何内容 - 使用 * 以外的任何内容作为 [=23 的约束是很不常见的=] 扩展名):

composer show -p