com\setasign\SetaFramework\Http
HttpFactory Class HttpFactory
File: /SetaFramework/src/Http/HttpFactory.php
Class hierarchy
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
- HttpFactoryInterface
Summary
Properties
$requestFactory
$requestPathPrefix
$responseFactory
$serverRequestFactory
$streamFactory
$uploadFileFactory
$uriFactory
Methods
__construct()
\Psr\Http\Message\ResponseFactoryInterface $responseFactory,
\Psr\Http\Message\ServerRequestFactoryInterface $serverRequestFactory,
\Psr\Http\Message\StreamFactoryInterface $streamFactory,
\Psr\Http\Message\UploadedFileFactoryInterface $uploadFileFactory,
\Psr\Http\Message\UriFactoryInterface $uriFactory,
\com\setasign\SetaFramework\Bootstrap\RequestPathPrefix $requestPathPrefix
Parameters
- $requestFactory : \Psr\Http\Message\RequestFactoryInterface
- $responseFactory : \Psr\Http\Message\ResponseFactoryInterface
- $serverRequestFactory : \Psr\Http\Message\ServerRequestFactoryInterface
- $streamFactory : \Psr\Http\Message\StreamFactoryInterface
- $uploadFileFactory : \Psr\Http\Message\UploadedFileFactoryInterface
- $uriFactory : \Psr\Http\Message\UriFactoryInterface
- $requestPathPrefix : \com\setasign\SetaFramework\Bootstrap\RequestPathPrefix
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
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 = ''
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 ( )
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.
createStreamFromFile()
string $mode = 'r'
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()
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
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.
createUri()
Parameters
- $uri : string
Exceptions
Throws \InvalidArgumentException If the given URI cannot be parsed.
