简体   繁体   English

作曲家:覆盖对PHP版本的传递依赖

[英]Composer: Override Transitive Dependency on PHP Version

I'm working on a project that uses guzzlehttp/guzzle. 我正在使用guzzlehttp / guzzle的项目中工作。

While our production servers use PHP 5.4, our build box is still on 5.3, so when it runs a composer install , we see the following error: 当我们的生产服务器使用PHP 5.4时,我们的构建框仍在5.3上,因此当它运行composer install ,我们看到以下错误:

guzzlehttp/guzzle 4.2.x-dev requires php >=5.4.0 -> no matching package found.

Is there any way to override this? 有什么办法可以覆盖吗? I've requiring php 5.3 "as" 5.4.0, but it then complained that the package 'php' couldn't be found. 我需要php 5.3“ as” 5.4.0,但随后它抱怨找不到软件包'php'。

It seems that requiring a PHP version is a special case of a package and doesn't allow the same overrides provided for normal packages. 似乎要求PHP版本是软件包的一种特殊情况,并且不允许为普通软件包提供相同的替代。 Is there a way around this? 有没有解决的办法?

I don't know of a way around this. 我不知道如何解决这个问题。

The problem is: How should Composer know about the PHP that is supposed to execute the code in contrast to the PHP that is just grapping it's dependencies. 问题是:与仅捕获其依赖项的PHP相反,Composer应该如何了解应该执行代码的PHP。 Currently there is no way to override either PHP versions or installed extensions. 当前无法覆盖PHP版本或已安装的扩展。

And where should this override be put? 那该放在哪里呢? It's wrong to put it into the composer.json , because that would change the detected PHP version Composer assumes, and will lead to conflicts. 将其放入composer.json是错误的,因为这将更改Composer假定的检测到的PHP版本,并会导致冲突。 It should probably be some sort of configuration of the local Composer instance that is being used to override the assumed PHP version. 可能应该是用于替代假定的PHP版本的本地Composer实例的某种配置。

I'd suggest upgrading your build box to 5.4 or install an additional version of PHP 5.4 that is only used for Composer. 我建议将您的构建盒升级到5.4或安装一个仅用于Composer的PHP 5.4附加版本。

How would you detect version conflicts on that build box during test execution if you do not use the PHP version that is supposed to run the code? 如果您不使用应该运行代码的PHP版本,那么在测试执行期间如何在该构建框中检测版本冲突?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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