This library creates simple way bind the interface and http call to foreign endpoint
composer require larexsetch/http-client-binder
You can see example here: HttpClientBinder\Tests\Base\Client\ClientInterface
<?php
/** @var YourClientInterface $client */
$client =
\HttpClientBinder\Fabrics\BinderBuilder::builder()
->temporaryDirectory("/path/to/temporary/directory") // Default /tmp
->encoder($encoder) // Custom encoder
->decoder($decoder) // Custom decoder
->target(YourClientInterface::class, $baseUrl) // $baseUrl may be declare by annotation @Client(baseUrl="http://example.com")
->getClient();