-
Notifications
You must be signed in to change notification settings - Fork 9
GuzzleHttp conflicts #5
Comments
Hey Fabian,
Thanks! |
Hey @jon-batscha, @HHFabian is actually on vacation so i will give the answers for him: |
Did some more research into this, and it looks like you can solve it relatively simply, as follows: Create a separate, blank folder for the Klaviyo installation, in which you will run Now, wherever you wish to use the Klaviyo SDK, you can import it as follows:
Now your script will have access to the Klaviyo SDK, but it will be installed in such a way that it can have its required version of guzzle without impacting your shopware installation. |
Hey @jon-batscha, this does not work for us. We do have this library in an extra folder (plugins/klaviyo), with a own composer.json file and its required there. Also there is a vendor folder in this folder, where guzzle 7.3 is included and also klaviyo-php-sdk. We then have a custom composer loader which: We then use the shopware internal dependency injection system (which is based on the symfony dependency injection container) to bootstrap the required classes (this uses composer as well). We then want to inject the https://github.com/klaviyo/klaviyo-php-sdk/blob/main/lib/Client.php into the class, which is working really well. But your Client just use "GuzzleHttp\Client" which causes the composer autoloading to get the guzzle 5.3.3 client located at vendor/guzzlehttp/guzzle instead of using plugins/klaviyo/vendor/guzzlehttp/guzzle. In this old version, there is no PSR7 interface etc, which causes Problems when sending requests to your API. We also checked what happens if we just try to find out which class composer wants to load with As said before; everything works well in Unit-Tests where Guzzle7.3 is normally loaded without 5.3.3. But it does not work when using it in the real bootstrapped Shopware Application. You could search the web and see that there are often Problems with having different Guzzle versions in a project and problems with autoloading like: I hope our problem now is a bit more clear and you can help us out with changing the namespace or having any other ideas :) |
Appreciate you taking the time to reply in detail. As I understand, there are 3 possible solutions:
Apologies I couldn't more helpful here. I'll keep an eye on this issue, and if anything changes, I'll be sure to follow-up with any new learnings. |
Hey Klaviyo Team,
we use Shopware and use this SDK for a plugin. The problem we now have is that Shopware in our version still uses GuzzleHttp in version 5.3.3 and the SDK itself ^7.3. This leads to conflicts on our side and triggers errors. Is it possible to adjust the GuzzleHttp namespace to GuzzleHttp7 or GuzzleHttp73 in the SDK itself to prevent conflicts? A lot bigger non-Shopware codebases also use maybe old versions of guzzle, so this would enhance compability over various clients.
Best regards,
Fabian
The text was updated successfully, but these errors were encountered: