通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
[TOC] ## 安装 ``` composer require psr/http-factory ``` ## 接口 <details> <summary>Psr\Http\Message\RequestFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; interface RequestFactoryInterface { /** * 创建一个新的请求 * * @param string $method 请求使用的 HTTP 方法。 * @param UriInterface|string $uri 请求关联的 URI。 */ public function createRequest(string $method, $uri): RequestInterface; } ``` </details> <br /> <details> <summary>Psr\Http\Message\ResponseFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\ResponseInterface; interface ResponseFactoryInterface { /** * 创建一个响应对象。 * * @param int $code HTTP 状态码,默认值为 200。 * @param string $reasonPhrase 与状态码关联的原因短语。如果未提供,实现 **可能** 使用 HTTP 规范中建议的值。 */ public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface; } ``` </details> <br /> <details> <summary>Psr\Http\Message\ServerRequestFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UriInterface; interface ServerRequestFactoryInterface { /** * 创建一个服务端请求。 * * 注意服务器参数要精确的按给定的方式获取 - 不执行给定值的解析或处理。 * 尤其是不要从中尝试获取 HTTP 方法或 URI,这两个信息一定要通过函数参数明确给出。 * * @param string $method 与请求关联的 HTTP 方法。 * @param UriInterface|string $uri 与请求关联的 URI。 * @param array $serverParams 用来生成请求实例的 SAPI 参数。 */ public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface; } ``` </details> <br /> <details> <summary>Psr\Http\Message\StreamFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\StreamInterface; interface StreamFactoryInterface { /** * 从字符串创建一个流。 * * 流 **应该** 使用临时资源来创建。 * * @param string $content 用于填充流的字符串内容。 */ public function createStream(string $content = ''): StreamInterface; /** * 通过现有文件创建一个流。 * * 文件 **必须** 用给定的模式打开文件,该模式可以是 `fopen` 函数支持的任意模式。 * * `$filename` **可能** 是任意被 `fopen()` 函数支持的字符串。 * * @param string $filename 用作流基础的文件名或 URI。 * @param string $mode 用于打开基础文件名或流的模式。 * * @throws \RuntimeException 如果文件无法被打开时抛出。 * @throws \InvalidArgumentException 如果模式无效会被抛出。 */ public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface; /** * 通过现有资源创建一个流。 * * 流必须是可读的并且可能是可写的。 * * @param resource $resource 用作流的基础的 PHP 资源。 */ public function createStreamFromResource($resource): StreamInterface; } ``` </details> <br /> <details> <summary>Psr\Http\Message\UploadedFileFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; interface UploadedFileFactoryInterface { /** * 创建一个上传文件接口的对象。 * * 如果未提供大小,将通过检查流的大小来确定。 * * @link http://php.net/manual/features.file-upload.post-method.php * @link http://php.net/manual/features.file-upload.errors.php * * @param StreamInterface $stream 表示上传文件内容的流。 * @param int $size 文件的大小,以字节为单位。 * @param int $error PHP 上传文件的错误码。 * @param string $clientFilename 如果存在,客户端提供的文件名。 * @param string $clientMediaType 如果存在,客户端提供的媒体类型。 * * @throws \InvalidArgumentException 如果文件资源不可读时抛出异常。 */ public function createUploadedFile( StreamInterface $stream, int $size = null, int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null ): UploadedFileInterface; } ``` </details> <br /> <details> <summary>Psr\Http\Message\UriFactoryInterface</summary> ``` namespace Psr\Http\Message; use Psr\Http\Message\UriInterface; interface UriFactoryInterface { /** * 创建一个 URI。 * * @param string $uri 要解析的 URI。 * * @throws \InvalidArgumentException 如果给定的 URI 无法被解析时抛出。 */ public function createUri(string $uri = '') : UriInterface; } ``` </details> <br />