I am implementing a payment method module, for a payment provider company.
That company has a proprietary php-sdk for all the actions around the payment requests. That sdk uses guzzlehttp/guzzle
.
I have required the sdk in the magento module, which in turns has guzzle
as its own dependency and so it requires that and everything else.
Now when I run php bin/magento setup:di:compile
I get the error that ClientTrait
is already declared, because I found Guzzle being installed already in the Magento core.
The solution seems to be php-scoper but I failed to make it work and also failed to find any help online or examples of other modules who have done this.
The steps I have taken are:
- Install
php-scoper
- Run `php-scoper add-prefix –prefix=[our unique prefix] vendor/
- Run
php bin/magento setup:di:compile
- Encounter error:
Interface "[Our Prefix]GuzzleHttpBodySummarizerInterface" not found
The interface is there:
/guzzlehttp/guzzle/src/BodySummarizerInterface.php
:
<?php
namespace [Prefix]GuzzleHttp;
use [Prefix]PsrHttpMessageMessageInterface;
/** @internal */
interface BodySummarizerInterface
{
/**
* Returns a summarized message body.
*/
public function summarize(MessageInterface $message) : ?string;
}
So my question is, what are the steps I need to follow in order to load the sdk that already contains the Guzzle client and is currently conflicting with another Guzzle installation?