Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

CakePHP Adapter

An HTTPlug adapter for the CakePHP HTTP client.


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

$ composer require php-http/cakephp-adapter


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

use Cake\Http\Client as CakeClient;

$config = [
    // Config params
$cakeClient = new CakeClient($config);

Then create the adapter:

use Http\Adapter\Cake\Client as CakeAdapter;
use Http\Message\MessageFactory\GuzzleMessageFactory;

$adapter = new CakeAdapter($cakeClient, new GuzzleMessageFactory());


The client parameter is optional; if you do not supply it (or set it to null) the adapter will create a default CakePHP HTTP client without any options.

Or if you installed the :doc:`discovery </discovery>` layer:

use Http\Adapter\Cake\Client as CakeAdapter;

$adapter = new CakeAdapter($cakeClient);


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