Symfony Client
The Symfony HTTP client provides a HttplugClient
class that implements the Http\Client\HttpAsyncClient
.
Until Symfony 5.4, it also implemented the Http\Client\HttpClient
, newer versions implement the PSR-18
HttpClientInterface
instead.
Installation
The Symfony client does not depend on HTTPlug, but the HttplugClient
does. To use the Symfony client with HTTPlug,
you need to install both the client and HTTPlug with:
$ composer require symfony/http-client php-http/httplug
This client does not come with a PSR-7 implementation out of the box. If you do
not require one, discovery <../discovery> will install Nyholm PSR-7. If
you do not allow the composer plugin of the php-http/discovery
component,
you need to install a PSR-7 implementation manually:
$ composer require nyholm/psr7
Usage
use Symfony\Component\HttpClient\HttplugClient;
$symfonyClient = new HttplugClient();
Note
Check the official Symfony HttpClient documentation for more details.