Psr18Client
in package
implements
ClientInterface, RequestFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ResetInterface
An adapter to turn a Symfony HttpClientInterface into a PSR-18 ClientInterface.
Run "composer require psr/http-client" to install the base ClientInterface. Run "composer require nyholm/psr7" to install an efficient implementation of response and stream factories with flex-provided autowiring aliases.
Tags
Table of Contents
Interfaces
- ClientInterface
- RequestFactoryInterface
- StreamFactoryInterface
- UriFactoryInterface
- ResetInterface
- Provides a way to reset an object to its initial state.
Properties
- $client : mixed
- $responseFactory : mixed
- $streamFactory : mixed
Methods
- __construct() : mixed
- createRequest() : RequestInterface
- Create a new request.
- createStream() : StreamInterface
- Create a new stream from a string.
- createStreamFromFile() : StreamInterface
- Create a stream from an existing file.
- createStreamFromResource() : StreamInterface
- Create a new stream from an existing resource.
- createUri() : UriInterface
- Create a new URI.
- reset() : mixed
- sendRequest() : ResponseInterface
- Sends a PSR-7 request and returns a PSR-7 response.
Properties
$client
private
mixed
$client
$responseFactory
private
mixed
$responseFactory
$streamFactory
private
mixed
$streamFactory
Methods
__construct()
public
__construct([HttpClientInterface|null $client = null ][, ResponseFactoryInterface|null $responseFactory = null ][, StreamFactoryInterface|null $streamFactory = null ]) : mixed
Parameters
- $client : HttpClientInterface|null = null
- $responseFactory : ResponseFactoryInterface|null = null
- $streamFactory : StreamFactoryInterface|null = null
createRequest()
Create a new request.
public
createRequest(string $method, mixed $uri) : RequestInterface
Parameters
- $method : string
-
The HTTP method associated with the request.
- $uri : mixed
-
The URI associated with the request. If the value is a string, the factory MUST create a UriInterface instance based on it.
Return values
RequestInterfacecreateStream()
Create a new stream from a string.
public
createStream([string $content = '' ]) : StreamInterface
Parameters
- $content : string = ''
-
String content with which to populate the stream.
Return values
StreamInterfacecreateStreamFromFile()
Create a stream from an existing file.
public
createStreamFromFile(string $filename[, string $mode = 'r' ]) : StreamInterface
Parameters
- $filename : string
-
Filename or stream URI to use as basis of stream.
- $mode : string = 'r'
-
Mode with which to open the underlying filename/stream.
Return values
StreamInterfacecreateStreamFromResource()
Create a new stream from an existing resource.
public
createStreamFromResource(mixed $resource) : StreamInterface
Parameters
- $resource : mixed
-
PHP resource to use as basis of stream.
Return values
StreamInterfacecreateUri()
Create a new URI.
public
createUri([string $uri = '' ]) : UriInterface
Parameters
- $uri : string = ''
Return values
UriInterfacereset()
public
reset() : mixed
sendRequest()
Sends a PSR-7 request and returns a PSR-7 response.
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface