Prestashop 1.6,冲突:2个不同的模块需要相同的类,不同的版本 [英] Prestashop 1.6, conflict: 2 different modules requiring same class, different versions

查看:95
本文介绍了Prestashop 1.6,冲突:2个不同的模块需要相同的类,不同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Prestashop项目中,我有几个模块.在其中一个(我们称其为"AWS")中,我使用composer(在PHPStorm中)安装了 AWS SDK ,如

In my Prestashop project, I have several modules. In one of them (let's call it "AWS") I installed AWS SDK using composer (in PHPStorm), as explained here. Composer has "required", among other libraries, "guzzlehttp", updated to its final version.

另一方面,还有另一个带有作曲器的模块(我们称其为"orangeConnect" ),该模块的早期版本为"guzzlehttp".

On the other hand, there is another module (let's call it "orangeConnect") with composer too, that has an earlier version of "guzzlehttp".

问题出在当我在第一个模块中的php脚本内的php中使用AWS开发工具包时.发生的情况是它尝试调用URI Composer类,并且崩溃了.实际上,由于不存在一个类"UriResolver".问题是,如果我删除"orangeConnect",则AWS开发工具包将正确连接,这意味着由于"orangeConnect"模块,"AWS"中的类Uri无法正确使用.但是,我迫切需要在项目中支持"orangeConnect".

The problem lies when I am using AWS SDK in php, inside a php script in the first module. What happens is that it tries to call the URI Composer class and it crashes. Actually, because of the inexistence of one class "UriResolver". The thing is that if I remove "orangeConnect" then AWS SDK connect correctly, which means that the class Uri, in "AWS" is not taken correctly because of "orangeConnect" module. However, I need imperatively to support "orangeConnect" in the project.

总而言之,我如何解决Prestashop中PHP类之间的冲突,并允许每个模块包含相应的有效版本的guzzleHttp,没有任何冲突 ?

How can I, in summary, solve this conflict between classes in PHP inside Prestashop and allow each module to include the corresponding valid version of guzzleHttp without conflicts of any kind?

谢谢.

推荐答案

如果orangeConnect模块的官方维护者没有升级代码,则只能采用3种方法:

If the official maintainer of orangeConnect module doesn't upgrade the code, there are only 3 methods you can take:

方法1:您可以维护自己的orangeConnect代码的副本,并升级到最新的Guzzle.通常,这并不困难,因为Guzzle的界面设计合理.

Method 1: You can maintain a copy of your own orangeConnect code, and upgrade to latest Guzzle. Usually it won't be to difficult because Guzzle's interface are well designed.

方法2:获取旧的Guzzle代码并将其放入新的命名空间(例如:OldGuzzle),并使orangeConnect使用OldGuzzle命名空间.您可以通过简单地执行全局正则表达式替换来实现此目的.

Method 2: Get the old Guzzle's code and put it into a new namespace (eg: OldGuzzle) and make orangeConnect use OldGuzzle namespace. You can achieve this by do a global regex replace simply.

方法3 :(仅适用于大型系统)将PHP应用程序划分为微服务模块,并隔离orangeConnectAWS SDK,并使它们使用不同的Guzzle.

Method 3: (Only for big systems) Divide your PHP application to micro-service modules, and isolate orangeConnect and AWS SDK and make them use different Guzzle.

这篇关于Prestashop 1.6,冲突:2个不同的模块需要相同的类,不同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆