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
This client does not come with a PSR-7 implementation out of the box, so you have to install one as well (for example Guzzle PSR-7):
$ composer require guzzlehttp/psr7
In order to provide full interoperability, message implementations are accessed through factories. Message factories for Laminas Diactoros (and its abandoned predecessor Zend Diactoros), Guzzle PSR-7 and `Slim Framework`_ are available in the message component:
$ composer require php-http/message
Alternatively you can install the discovery layer to be able to automatically find installed resources, like factories:
$ composer require php-http/discovery
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 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.