Psr7
Interfaces, Classes, Traits and Enums
- AppendStream
- Reads from multiple streams, one after the other.
- BufferStream
- Provides a buffer stream that can be written to to fill a buffer, and read from to remove bytes from the buffer.
- CachingStream
- Stream decorator that can cache previously read bytes from a sequentially read stream.
- DroppingStream
- Stream decorator that begins dropping data once the size of the underlying stream becomes too full.
- FnStream
- Compose stream implementations based on a hash of functions.
- InflateStream
- Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
- LazyOpenStream
- Lazily reads or writes to a file that is opened only after an IO operation take place on the stream.
- LimitStream
- Decorator used to return only a subset of a stream
- MultipartStream
- Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.
- NoSeekStream
- Stream decorator that prevents a stream from being seeked
- PumpStream
- Provides a read only stream that pumps data from a PHP callable.
- Request
- PSR-7 request implementation.
- Response
- PSR-7 response implementation.
- Rfc7230
- ServerRequest
- Server-side HTTP request
- Stream
- PHP stream implementation.
- StreamWrapper
- Converts Guzzle streams into PHP stream resources.
- UploadedFile
- Uri
- PSR-7 URI implementation.
- UriNormalizer
- Provides methods to normalize and compare URIs.
- UriResolver
- Resolves a URI reference in the context of a base URI and the opposite way.
- AppendStream
- Reads from multiple streams, one after the other.
- BufferStream
- Provides a buffer stream that can be written to to fill a buffer, and read from to remove bytes from the buffer.
- CachingStream
- Stream decorator that can cache previously read bytes from a sequentially read stream.
- DroppingStream
- Stream decorator that begins dropping data once the size of the underlying stream becomes too full.
- FnStream
- Compose stream implementations based on a hash of functions.
- InflateStream
- Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
- LazyOpenStream
- Lazily reads or writes to a file that is opened only after an IO operation take place on the stream.
- LimitStream
- Decorator used to return only a subset of a stream
- MultipartStream
- Stream that when read returns bytes for a streaming multipart or multipart/form-data stream.
- NoSeekStream
- Stream decorator that prevents a stream from being seeked
- PumpStream
- Provides a read only stream that pumps data from a PHP callable.
- Request
- PSR-7 request implementation.
- Response
- PSR-7 response implementation.
- Rfc7230
- ServerRequest
- Server-side HTTP request
- Stream
- PHP stream implementation.
- StreamWrapper
- Converts Guzzle streams into PHP stream resources.
- UploadedFile
- Uri
- PSR-7 URI implementation.
- UriNormalizer
- Provides methods to normalize and compare URIs.
- UriResolver
- Resolves a URI reference in the context of a base URI and the opposite way.
- MessageTrait
- Trait implementing functionality common to requests and responses.
- StreamDecoratorTrait
- Stream decorator trait
- MessageTrait
- Trait implementing functionality common to requests and responses.
- StreamDecoratorTrait
- Stream decorator trait
Table of Contents
- str() : string
- Returns the string representation of an HTTP message.
- uri_for() : UriInterface
- Returns a UriInterface for the given value.
- stream_for() : StreamInterface
- Create a new stream based on the input type.
- parse_header() : array<string|int, mixed>
- Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
- normalize_header() : array<string|int, mixed>
- Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.
- modify_request() : RequestInterface
- Clone and modify a request with the given changes.
- rewind_body() : mixed
- Attempts to rewind a message body and throws an exception on failure.
- try_fopen() : resource
- Safely opens a PHP stream resource using a filename.
- copy_to_string() : string
- Copy the contents of a stream into a string until the given number of bytes have been read.
- copy_to_stream() : mixed
- Copy the contents of a stream into another stream until the given number of bytes have been read.
- hash() : string
- Calculate a hash of a Stream
- readline() : string
- Read a line from the stream up to the maximum allowed buffer length
- parse_request() : Request
- Parses a request message string into a request object.
- parse_response() : Response
- Parses a response message string into a response object.
- parse_query() : array<string|int, mixed>
- Parse a query string into an associative array.
- build_query() : string
- Build a query string from an array of key value pairs.
- mimetype_from_filename() : null|string
- Determines the mimetype of a file by looking at its extension.
- mimetype_from_extension() : string|null
- Maps a file extensions to a mimetype.
- get_message_body_summary() : null|string
- Get a short summary of the message body
- str() : string
- Returns the string representation of an HTTP message.
- uri_for() : UriInterface
- Returns a UriInterface for the given value.
- stream_for() : StreamInterface
- Create a new stream based on the input type.
- parse_header() : array<string|int, mixed>
- Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
- normalize_header() : array<string|int, mixed>
- Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.
- modify_request() : RequestInterface
- Clone and modify a request with the given changes.
- rewind_body() : mixed
- Attempts to rewind a message body and throws an exception on failure.
- try_fopen() : resource
- Safely opens a PHP stream resource using a filename.
- copy_to_string() : string
- Copy the contents of a stream into a string until the given number of bytes have been read.
- copy_to_stream() : mixed
- Copy the contents of a stream into another stream until the given number of bytes have been read.
- hash() : string
- Calculate a hash of a Stream
- readline() : string
- Read a line from the stream up to the maximum allowed buffer length
- parse_request() : Request
- Parses a request message string into a request object.
- parse_response() : Response
- Parses a response message string into a response object.
- parse_query() : array<string|int, mixed>
- Parse a query string into an associative array.
- build_query() : string
- Build a query string from an array of key value pairs.
- mimetype_from_filename() : null|string
- Determines the mimetype of a file by looking at its extension.
- mimetype_from_extension() : string|null
- Maps a file extensions to a mimetype.
- get_message_body_summary() : null|string
- Get a short summary of the message body
Functions
str()
Returns the string representation of an HTTP message.
str(MessageInterface $message) : string
Parameters
- $message : MessageInterface
-
Message to convert to a string.
Return values
string —uri_for()
Returns a UriInterface for the given value.
uri_for(string|UriInterface $uri) : UriInterface
This function accepts a string or UriInterface and
returns a UriInterface for the given value. If the value is already a
UriInterface
, it is returned as-is.
Parameters
- $uri : string|UriInterface
Tags
Return values
UriInterface —stream_for()
Create a new stream based on the input type.
stream_for([resource|string|null|int|float|bool|StreamInterface|callable|Iterator $resource = '' ][, array<string|int, mixed> $options = [] ]) : StreamInterface
Options is an associative array that can contain the following keys:
- metadata: Array of custom metadata.
- size: Size of the stream.
Parameters
- $resource : resource|string|null|int|float|bool|StreamInterface|callable|Iterator = ''
-
Entity body data
- $options : array<string|int, mixed> = []
-
Additional options
Tags
Return values
StreamInterface —parse_header()
Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
parse_header(string|array<string|int, mixed> $header) : array<string|int, mixed>
Parameters
- $header : string|array<string|int, mixed>
-
Header to parse into components.
Return values
array<string|int, mixed> —Returns the parsed header values.
normalize_header()
Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.
normalize_header(string|array<string|int, mixed> $header) : array<string|int, mixed>
Parameters
- $header : string|array<string|int, mixed>
-
Header to normalize.
Return values
array<string|int, mixed> —Returns the normalized header field values.
modify_request()
Clone and modify a request with the given changes.
modify_request(RequestInterface $request, array<string|int, mixed> $changes) : RequestInterface
The changes can be one of:
- method: (string) Changes the HTTP method.
- set_headers: (array) Sets the given headers.
- remove_headers: (array) Remove the given headers.
- body: (mixed) Sets the given body.
- uri: (UriInterface) Set the URI.
- query: (string) Set the query string value of the URI.
- version: (string) Set the protocol version.
Parameters
- $request : RequestInterface
-
Request to clone and modify.
- $changes : array<string|int, mixed>
-
Changes to apply.
Return values
RequestInterface —rewind_body()
Attempts to rewind a message body and throws an exception on failure.
rewind_body(MessageInterface $message) : mixed
The body of the message will only be rewound if a call to tell()
returns a
value other than 0
.
Parameters
- $message : MessageInterface
-
Message to rewind
Tags
Return values
mixed —try_fopen()
Safely opens a PHP stream resource using a filename.
try_fopen(string $filename, string $mode) : resource
When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead.
Parameters
- $filename : string
-
File to open
- $mode : string
-
Mode used to open the file
Tags
Return values
resource —copy_to_string()
Copy the contents of a stream into a string until the given number of bytes have been read.
copy_to_string(StreamInterface $stream[, int $maxLen = -1 ]) : string
Parameters
- $stream : StreamInterface
-
Stream to read
- $maxLen : int = -1
-
Maximum number of bytes to read. Pass -1 to read the entire stream.
Tags
Return values
string —copy_to_stream()
Copy the contents of a stream into another stream until the given number of bytes have been read.
copy_to_stream(StreamInterface $source, StreamInterface $dest[, int $maxLen = -1 ]) : mixed
Parameters
- $source : StreamInterface
-
Stream to read from
- $dest : StreamInterface
-
Stream to write to
- $maxLen : int = -1
-
Maximum number of bytes to read. Pass -1 to read the entire stream.
Tags
Return values
mixed —hash()
Calculate a hash of a Stream
hash(StreamInterface $stream, string $algo[, bool $rawOutput = false ]) : string
Parameters
- $stream : StreamInterface
-
Stream to calculate the hash for
- $algo : string
-
Hash algorithm (e.g. md5, crc32, etc)
- $rawOutput : bool = false
-
Whether or not to use raw output
Tags
Return values
string —Returns the hash of the stream
readline()
Read a line from the stream up to the maximum allowed buffer length
readline(StreamInterface $stream[, int $maxLength = null ]) : string
Parameters
- $stream : StreamInterface
-
Stream to read from
- $maxLength : int = null
-
Maximum buffer length
Return values
string —parse_request()
Parses a request message string into a request object.
parse_request(string $message) : Request
Parameters
- $message : string
-
Request message string.
Return values
Request —parse_response()
Parses a response message string into a response object.
parse_response(string $message) : Response
Parameters
- $message : string
-
Response message string.
Return values
Response —parse_query()
Parse a query string into an associative array.
parse_query(string $str[, int|bool $urlEncoding = true ]) : array<string|int, mixed>
If multiple values are found for the same key, the value of that key value pair will become an array. This function does not parse nested PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).
Parameters
- $str : string
-
Query string to parse
- $urlEncoding : int|bool = true
-
How the query string is encoded
Return values
array<string|int, mixed> —build_query()
Build a query string from an array of key value pairs.
build_query(array<string|int, mixed> $params[, int|false $encoding = PHP_QUERY_RFC3986 ]) : string
This function can use the return value of parse_query() to build a query string. This function does not modify the provided keys when an array is encountered (like http_build_query would).
Parameters
- $params : array<string|int, mixed>
-
Query string parameters.
- $encoding : int|false = PHP_QUERY_RFC3986
-
Set to false to not encode, PHP_QUERY_RFC3986 to encode using RFC3986, or PHP_QUERY_RFC1738 to encode using RFC1738.
Return values
string —mimetype_from_filename()
Determines the mimetype of a file by looking at its extension.
mimetype_from_filename( $filename) : null|string
Parameters
Return values
null|string —mimetype_from_extension()
Maps a file extensions to a mimetype.
mimetype_from_extension( $extension) : string|null
Parameters
Tags
Return values
string|null —get_message_body_summary()
Get a short summary of the message body
get_message_body_summary(MessageInterface $message[, int $truncateAt = 120 ]) : null|string
Will return null
if the response is not printable.
Parameters
- $message : MessageInterface
-
The message to get the body summary
- $truncateAt : int = 120
-
The maximum allowed size of the summary
Return values
null|string —str()
Returns the string representation of an HTTP message.
str(MessageInterface $message) : string
Parameters
- $message : MessageInterface
-
Message to convert to a string.
Return values
string —uri_for()
Returns a UriInterface for the given value.
uri_for(string|UriInterface $uri) : UriInterface
This function accepts a string or UriInterface and
returns a UriInterface for the given value. If the value is already a
UriInterface
, it is returned as-is.
Parameters
- $uri : string|UriInterface
Tags
Return values
UriInterface —stream_for()
Create a new stream based on the input type.
stream_for([resource|string|null|int|float|bool|StreamInterface|callable|Iterator $resource = '' ][, array<string|int, mixed> $options = [] ]) : StreamInterface
Options is an associative array that can contain the following keys:
- metadata: Array of custom metadata.
- size: Size of the stream.
Parameters
- $resource : resource|string|null|int|float|bool|StreamInterface|callable|Iterator = ''
-
Entity body data
- $options : array<string|int, mixed> = []
-
Additional options
Tags
Return values
StreamInterface —parse_header()
Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
parse_header(string|array<string|int, mixed> $header) : array<string|int, mixed>
Parameters
- $header : string|array<string|int, mixed>
-
Header to parse into components.
Return values
array<string|int, mixed> —Returns the parsed header values.
normalize_header()
Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.
normalize_header(string|array<string|int, mixed> $header) : array<string|int, mixed>
Parameters
- $header : string|array<string|int, mixed>
-
Header to normalize.
Return values
array<string|int, mixed> —Returns the normalized header field values.
modify_request()
Clone and modify a request with the given changes.
modify_request(RequestInterface $request, array<string|int, mixed> $changes) : RequestInterface
The changes can be one of:
- method: (string) Changes the HTTP method.
- set_headers: (array) Sets the given headers.
- remove_headers: (array) Remove the given headers.
- body: (mixed) Sets the given body.
- uri: (UriInterface) Set the URI.
- query: (string) Set the query string value of the URI.
- version: (string) Set the protocol version.
Parameters
- $request : RequestInterface
-
Request to clone and modify.
- $changes : array<string|int, mixed>
-
Changes to apply.
Return values
RequestInterface —rewind_body()
Attempts to rewind a message body and throws an exception on failure.
rewind_body(MessageInterface $message) : mixed
The body of the message will only be rewound if a call to tell()
returns a
value other than 0
.
Parameters
- $message : MessageInterface
-
Message to rewind
Tags
Return values
mixed —try_fopen()
Safely opens a PHP stream resource using a filename.
try_fopen(string $filename, string $mode) : resource
When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead.
Parameters
- $filename : string
-
File to open
- $mode : string
-
Mode used to open the file
Tags
Return values
resource —copy_to_string()
Copy the contents of a stream into a string until the given number of bytes have been read.
copy_to_string(StreamInterface $stream[, int $maxLen = -1 ]) : string
Parameters
- $stream : StreamInterface
-
Stream to read
- $maxLen : int = -1
-
Maximum number of bytes to read. Pass -1 to read the entire stream.
Tags
Return values
string —copy_to_stream()
Copy the contents of a stream into another stream until the given number of bytes have been read.
copy_to_stream(StreamInterface $source, StreamInterface $dest[, int $maxLen = -1 ]) : mixed
Parameters
- $source : StreamInterface
-
Stream to read from
- $dest : StreamInterface
-
Stream to write to
- $maxLen : int = -1
-
Maximum number of bytes to read. Pass -1 to read the entire stream.
Tags
Return values
mixed —hash()
Calculate a hash of a Stream
hash(StreamInterface $stream, string $algo[, bool $rawOutput = false ]) : string
Parameters
- $stream : StreamInterface
-
Stream to calculate the hash for
- $algo : string
-
Hash algorithm (e.g. md5, crc32, etc)
- $rawOutput : bool = false
-
Whether or not to use raw output
Tags
Return values
string —Returns the hash of the stream
readline()
Read a line from the stream up to the maximum allowed buffer length
readline(StreamInterface $stream[, int $maxLength = null ]) : string
Parameters
- $stream : StreamInterface
-
Stream to read from
- $maxLength : int = null
-
Maximum buffer length
Return values
string —parse_request()
Parses a request message string into a request object.
parse_request(string $message) : Request
Parameters
- $message : string
-
Request message string.
Return values
Request —parse_response()
Parses a response message string into a response object.
parse_response(string $message) : Response
Parameters
- $message : string
-
Response message string.
Return values
Response —parse_query()
Parse a query string into an associative array.
parse_query(string $str[, int|bool $urlEncoding = true ]) : array<string|int, mixed>
If multiple values are found for the same key, the value of that key value pair will become an array. This function does not parse nested PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).
Parameters
- $str : string
-
Query string to parse
- $urlEncoding : int|bool = true
-
How the query string is encoded
Return values
array<string|int, mixed> —build_query()
Build a query string from an array of key value pairs.
build_query(array<string|int, mixed> $params[, int|false $encoding = PHP_QUERY_RFC3986 ]) : string
This function can use the return value of parse_query() to build a query string. This function does not modify the provided keys when an array is encountered (like http_build_query would).
Parameters
- $params : array<string|int, mixed>
-
Query string parameters.
- $encoding : int|false = PHP_QUERY_RFC3986
-
Set to false to not encode, PHP_QUERY_RFC3986 to encode using RFC3986, or PHP_QUERY_RFC1738 to encode using RFC1738.
Return values
string —mimetype_from_filename()
Determines the mimetype of a file by looking at its extension.
mimetype_from_filename( $filename) : null|string
Parameters
Return values
null|string —mimetype_from_extension()
Maps a file extensions to a mimetype.
mimetype_from_extension( $extension) : string|null
Parameters
Tags
Return values
string|null —get_message_body_summary()
Get a short summary of the message body
get_message_body_summary(MessageInterface $message[, int $truncateAt = 120 ]) : null|string
Will return null
if the response is not printable.
Parameters
- $message : MessageInterface
-
The message to get the body summary
- $truncateAt : int = 120
-
The maximum allowed size of the summary