Features: LastRequestInfoCollector, MiddlewareSupporting
HTTPlug is a HTTP client abstraction that can be used with multiple client packages. With this handler it is easy to get in control about the HTTP layer of the SOAP client. You can specify one or multiple middlewares that are being applied on your http client. This makes it possible to manipulate the request and response objects so that you can get full control.
This handler knows how to deal with HTTP middlewares if they are supported by your HTTP client. You can read more about middlewares in this section.
Dependencies
Load HTTP plug core packages:
composer require psr/http-message:^1.0 php-http/httplug:^1.1 php-http/message-factory:^1.0 php-http/discovery:^1.3 php-http/message:^1.6 php-http/client-common:^1.6
Select HTTP Client
Select one of the many clients you want to use to perform the HTTP requests: http://docs.php-http.org/en/latest/clients.html#clients-adapters
composer require php-http/client-implementation:^1.0
Example usage
<?php
use Http\Adapter\Guzzle6\Client;
use Phpro\SoapClient\Middleware\BasicAuthMiddleware;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapEngineFactory;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions;
use Phpro\SoapClient\Soap\Handler\HttPlugHandle;
$handler = HttPlugHandle::createForClient(
Client::createWithConfig(['headers' => ['User-Agent' => 'testing/1.0']])
);
$handler->addMiddleware(new BasicAuthMiddleware('user', 'password'));
$engine = ExtSoapEngineFactory::fromOptionsWithHandler(
ExtSoapOptions::defaults($wsdl, []),
$handler
);
$client = new YourClient($engine, $eventDispatcher);