Guzzle5 Adapter (deprecated)

An HTTPlug adapter for the Guzzle 5 HTTP client.

This adapter only implements the PHP-HTTP synchronous interface. This interface has been superseded by PSR-18.

Guzzle 5 is very old and not maintained anymore. We recommend to upgrade to Guzzle version 7.


To install the Guzzle adapter, which will also install Guzzle itself (if it was not yet included in your project), run:

$ composer require php-http/guzzle5-adapter


Begin by creating a Guzzle client, passing any configuration parameters you like:

use GuzzleHttp\Client as GuzzleClient;

$config = [
    // Config params
$guzzle = new GuzzleClient($config);

Then create the adapter:

use Http\Adapter\Guzzle5\Client as GuzzleAdapter;
use Http\Message\MessageFactory\GuzzleMessageFactory;

$adapter = new GuzzleAdapter($guzzle, new GuzzleMessageFactory());

Or if you installed the discovery layer:

use Http\Adapter\Guzzle5\Client as GuzzleAdapter;

$adapter = new GuzzleAdapter($guzzle);


The message factory parameter is mandatory if the discovery layer is not installed.

Further reading

  • Use plugins to customize the way HTTP requests are sent and responses processed by following redirects, adding Authentication or Cookie headers and more.

  • Learn how you can decouple your code from any PSR-7 implementation by using the HTTP factories.