fastd/http
最新稳定版本:v5.0.0-alpha1
Composer 安装命令:
composer require fastd/http
包简介
FastD Http
README 文档
README
简单的 Http 协议组件, 用于解析 Http 请求信息, 实现 PSR-7 标准, 支持 Swoole 扩展.
以上库可以满足大部分 HTTP 请求处理相关工作, 支持 Swoole 处理, 具体请看项目Swoole。
要求
- php >= 5.6
安装
composer require "fastd/http" -vvv
文档
使用
HTTP 组件封装了常用的服务端解释,客户端请求,并且友好集成 Swoole Http Server 解析,实现PSR-7。
HTTP 组件没有对 Session 进行封装, 如果想在项目中支持 Session, 可以通过 Session 组件进行扩展.
获取 pathinfo
use FastD\Http\ServerRequest; $request = ServerRequest::createServerRequestFromGlobals(); $request->getUri()->getPath();
Swoole Http 服务器
$http = new swoole_http_server("127.0.0.1", 9501); $http->on('request', function ($request, $response) { $server = SwooleServerRequest::createServerRequestFromSwoole($request); $response->end($server->getUri()->getPath()); }); $http->start();
cURL 请求
Request 对象内部封装了 cURL 请求, 可以直接通过方法调用
$request = new Request('GET', 'https://api.github.com/'); $request->setReferrer('http://example.com/'); $response = $request->send(); // FastD\Http\Response
响应内容会通过 Response 对象返回。
贡献
非常欢迎感兴趣,愿意参与其中,共同打造更好PHP生态,Swoole生态的开发者。
如果你乐于此,却又不知如何开始,可以试试下面这些事情:
- 在你的系统中使用,将遇到的问题 反馈。
- 有更好的建议?欢迎联系 bboyjanhuang@gmail.com 或 新浪微博:编码侠。
联系
如果你在使用中遇到问题,请联系: bboyjanhuang@gmail.com. 微博: 编码侠
License MIT
统计信息
- 总下载量: 33.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 28
- 点击次数: 0
- 依赖项目数: 17
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-13