com\setasign\SetaFramework\Http
HttpFactoryInterface Interface HttpFactoryInterface
File: /SetaFramework/src/Http/HttpFactoryInterface.php
Implemented in
Implements
- \Psr\Http\Message\RequestFactoryInterface
- \Psr\Http\Message\ResponseFactoryInterface
- \Psr\Http\Message\ServerRequestFactoryInterface
- \Psr\Http\Message\StreamFactoryInterface
- \Psr\Http\Message\UploadedFileFactoryInterface
- \Psr\Http\Message\UriFactoryInterface
Summary
Methods
createHtmlResponse()
int $status = 200,
array $headers = array ( )
Parameters
- $html : string|\Psr\Http\Message\StreamInterface
HTML or stream for the message body.
- $status : int
Integer status code for the response; 200 by default.
- $headers : array
Array of headers to use at initialization.
createJsonResponse()
int $status = 200,
array $headers = array ( ),
int $encodingOptions = 79
Create a JSON response with the given data.
Default JSON encoding is performed with the following options, which produces RFC4627-compliant JSON, capable of embedding into HTML.
- JSON_HEX_TAG
- JSON_HEX_APOS
- JSON_HEX_AMP
- JSON_HEX_QUOT
- JSON_UNESCAPED_SLASHES
Parameters
- $data : mixed
Data to convert to JSON.
- $status : int
Integer status code for the response; 200 by default.
- $headers : array
Array of headers to use at initialization.
- $encodingOptions : int
JSON encoding options to use.
Exceptions
Throws \JsonException
createRedirectResponse()
bool $isExternal = false,
int $status = 302,
array $headers = array ( )
Parameters
- $uri : string|\Psr\Http\Message\UriInterface
- $isExternal : bool
If false the url will be prepended with the requestPathPrefix.
- $status : int
- $headers : array
createRequest()
-
\Psr\Http\Message\UriInterface|string $uri
Create a new request.
Parameters
- $method : string
The HTTP method associated with the request.
- $uri : \Psr\Http\Message\UriInterface|string
The URI associated with the request. If the value is a string, the factory MUST create a UriInterface instance based on it.
createResponse()
-
string $reasonPhrase = ''
Create a new response.
Parameters
- $code : int
HTTP status code; defaults to 200
- $reasonPhrase : string
Reason phrase to associate with status code in generated response; if none is provided implementations MAY use the defaults as suggested in the HTTP specification.
createServerRequest()
-
\Psr\Http\Message\UriInterface|string $uri,
array $serverParams = array ( )
Create a new server request.
Note that server-params are taken precisely as given - no parsing/processing of the given values is performed, and, in particular, no attempt is made to determine the HTTP method or URI, which must be provided explicitly.
Parameters
- $method : string
The HTTP method associated with the request.
- $uri : \Psr\Http\Message\UriInterface|string
The URI associated with the request. If the value is a string, the factory MUST create a UriInterface instance based on it.
- $serverParams : array
Array of SAPI parameters with which to seed the generated request instance.
createStream()
-
Create a new stream from a string.
The stream SHOULD be created with a temporary resource.
Parameters
- $content : string
String content with which to populate the stream.
createStreamFromFile()
-
string $mode = 'r'
Create a stream from an existing file.
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
Mode with which to open the underlying filename/stream.
Exceptions
Throws \RuntimeException If the file cannot be opened.
Throws \InvalidArgumentException If the mode is invalid.
createStreamFromResource()
-
Create a new stream from an existing resource.
The stream MUST be readable and may be writable.
Parameters
- $resource : resource
PHP resource to use as basis of stream.
createUploadedFile()
-
?int $size = null,
int $error = \UPLOAD_ERR_OK,
?string $clientFilename = null,
?string $clientMediaType = null
Create a new uploaded file.
If a size is not provided it will be determined by checking the size of the file.
Parameters
- $stream : \Psr\Http\Message\StreamInterface
Underlying stream representing the uploaded file content.
- $size : ?int
in bytes
- $error : int
PHP file upload error
- $clientFilename : ?string
Filename as provided by the client, if any.
- $clientMediaType : ?string
Media type as provided by the client, if any.
Exceptions
Throws \InvalidArgumentException If the file resource is not readable.
See
createUri()
-
Create a new URI.
Parameters
- $uri : string
Exceptions
Throws \InvalidArgumentException If the given URI cannot be parsed.
