跳过作曲家 PHP 要求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26165101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:12:09  来源:igfitidea点击:

Skip composer PHP requirement

phpcomposer-phpversioning

提问by Armin

We are using PHPCI and composer. The server which runs PHPCI is on PHP 5.3.

我们正在使用 PHPCI 和 Composer。运行 PHPCI 的服务器在 PHP 5.3 上。

For a project we added the Facebook PHP SDK, using composer. It requires PHP 5.4. Composer gets triggered by PHPCI and get executed. But because the CI server just got PHP 5.3 composer failed with the error message:

对于一个项目,我们使用 Composer 添加了 Facebook PHP SDK。它需要 PHP 5.4。Composer 被 PHPCI 触发并被执行。但是因为 CI 服务器刚刚得到 PHP 5.3 composer failed 并显示错误消息:

facebook/php-sdk-v4 4.0.9 requires php >=5.4.0 -> no matching package found.

This let fail my build in PHPCI, of course.

当然,这让我在 PHPCI 中的构建失败了。

Is there a possibility to skip this requirement? Maybe by adding an option to composer.json? Or a parameter to composer.phar call?

是否有可能跳过此要求?也许通过向 composer.json 添加一个选项?还是 composer.phar 调用的参数?

回答by Armin

I've found the option:

我找到了选项:

composer install --ignore-platform-reqs

Ignore platform requirements (php & ext- packages).

忽略平台要求(php 和 ext-packages)。



Edit:You can skip the platform checks with this, but Composer will fetch packages based on given PHP version then. So when you need composer to also emulate a PHP version during depedency resolving, you can (and should!) use this in your composer.json:

编辑:您可以跳过平台检查,但 Composer 将根据给定的 PHP 版本获取包。因此,当您需要 composer 在依赖解析期间模拟 PHP 版本时,您可以(并且应该!)在您的 composer.json 中使用它:

{
    "config": {
       "platform": {
           "php": "5.6.6"
       }
    }
}

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

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

回答by Luca C.

For many commands, you can tell composer to bypass php version check, with parameter "--ignore-platform-reqs":

对于许多命令,您可以通过参数“ --ignore-platform-reqs”告诉 composer 绕过 php 版本检查:

composer COMMAND --ignore-platform-reqs

this will bypass php version specification.

这将绕过 php 版本规范。

Be aware that the software may work or not: php version specification is there because somewhere in the code is needed at least the specified php version, so if you use that code the software will break.

请注意该软件可能有效与否:存在 php 版本规范,因为代码中的某处至少需要指定的 php 版本,因此如果您使用该代码,该软件将会中断。

回答by Wouter J

If anything requires a specific version of PHP, it won't run in a lower version of PHP. You will properbly still recieve errors when bypassing the PHP requirement.

如果任何东西需要特定版本的 PHP,它就不会在较低版本的 PHP 中运行。绕过 PHP 要求时,您仍然会收到错误消息。

Btw, PHP 5.3 is no longer maintained, I would strongly recommend updating the PHPCI server.

顺便说一句,PHP 5.3 不再维护,我强烈建议更新 PHPCI 服务器。