Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 1.4 KB

guzzle5-adapter.rst

File metadata and controls

55 lines (34 loc) · 1.4 KB

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.

Installation

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

Usage

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 </discovery> layer:

use Http\Adapter\Guzzle5\Client as GuzzleAdapter;

$adapter = new GuzzleAdapter($guzzle);

Warning

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