Psr18Client
in package
implements
ClientInterface, RequestFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ResetInterface
An adapter to turn a Symfony HttpClientInterface into a PSR-18 ClientInterface.
Run "composer require php-http/discovery psr/http-client-implementation:*" to get the required dependencies.
Tags
Table of Contents
Interfaces
- ClientInterface
- RequestFactoryInterface
- StreamFactoryInterface
- UriFactoryInterface
- ResetInterface
- Provides a way to reset an object to its initial state.
Properties
- $autoUpgradeHttpVersion : bool
- $client : HttpClientInterface
- $responseFactory : ResponseFactoryInterface
- $streamFactory : StreamFactoryInterface
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() : void
- sendRequest() : ResponseInterface
- withOptions() : static
Properties
$autoUpgradeHttpVersion
private
bool
$autoUpgradeHttpVersion
= true
$client
private
HttpClientInterface
$client
$responseFactory
private
ResponseFactoryInterface
$responseFactory
$streamFactory
private
StreamFactoryInterface
$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
The stream SHOULD be created with a temporary resource.
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
The file MUST be opened using the given mode, which may be any mode
supported by the fopen function.
The $filename MAY be any string supported by fopen().
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
The stream MUST be readable and may be writable.
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() : void
sendRequest()
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface
Return values
ResponseInterfacewithOptions()
public
withOptions(array<string|int, mixed> $options) : static
Parameters
- $options : array<string|int, mixed>