🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 请求 请求组件用来获取所有 HTTP 请求参数,基于 [PSR-7](https://www.php-fig.org/psr/psr-7/) / [PSR-17](https://www.php-fig.org/psr/psr-17/) 标准实现。 ## 组件 使用 [composer]([https://www.phpcomposer.com/](https://www.phpcomposer.com/)) 安装: ~~~ composer require mix/http-message ~~~ ## 来源 请求类定义于 `mix/http-message` 库,由 `mix/http-server` 的 `HandlerInterface::handleHTTP` 方法中获取,最终会传递到控制器的构造方法与调用方法中。 - [Router.php#L210](https://github.com/mix-php/route/blob/master/src/Router.php#L210) - [IndexController.php#L17](https://github.com/mix-php/mix-skeleton/tree/v2.1/app/Web/Controllers/IndexController.php#L17) ## PSR 定义方法 | 方法 | 描述 | | --- | --- | | getContext() : string | 获取上下文 | | getProtocolVersion() : string | 获取协议版本 | | getHeaders() : array | 获取全部header | | hasHeader($name) : bool | 判断 header 是否存在 | | getHeader($name) : array | 获取 header (http协议header是可以同名的) | | getHeaderLine($name) : string | 获取 header 单行 (逗号分隔) | | getBody() : StreamInterface | 获取主体原始内容 | | getMethod() : string | 获取请求方法 | | getUri() : UriInterface | 获取请求uri | | getSwooleRequest() : \Swoole\Http\Request | 获取 swoole 请求对象 | | getServerParams() : array | 获取服务器参数 | | getCookieParams() : array | 获取Cookie| | getQueryParams() : array | 获取请求参数 (GET) | | getUploadedFiles() : UploadedFileInterface[] | 获取上传文件 | | getParsedBody() : null \| array | 获取解析主体 (POST) | | getAttributes() : array | 获取全部属性 (GET/POST/Cookie) | | getAttribute($name, $default = null) | 获取属性 |