Prestashop 1.6, conflict: 2 different modules requiring same class, different versions

左心房为你撑大大i 提交于 2019-12-10 14:25:05

问题


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.

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

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.

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?

Thank you.


回答1:


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

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.

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.

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.



来源:https://stackoverflow.com/questions/48385669/prestashop-1-6-conflict-2-different-modules-requiring-same-class-different-ve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!