marcoazn89/http-wrapper
最新稳定版本:v2.1.1
Composer 安装命令:
composer require marcoazn89/http-wrapper
包简介
An HTTP wraper library
README 文档
README
composer require marcoazn89/http-wrapper:dev-dev
Features
- PSR-7 compliant response object
- Content negotiation
- Constants to avoid mistyping
- Flexibility to use outside of PSR-7
Create a new response object
require '../vendor/autoload.php'; $response = new \HTTP\Response();
Set headers
require '../vendor/autoload.php'; (new \HTTP\Response())->withType(\HTTP\Response\ContentType::JSON) ->write(['greeting' => 'Hello World'])->send();
Negotiate Headers
require '../vendor/autoload.php'; //Assuming the client send Accept:text/plain (new \HTTP\Response())->withTypeNegotiation()->write("Test")->send();
Set limits on what you can support
The order in which you add support matters! This will ignore any Accept headers that don't match the supported types.
require '../vendor/autoload.php'; use HTTP\Support\TypeSupport; use HTTP\Response\ContentType; // Add content you can support TypeSupport::addSupport([ ContentType::HTML, ContentType::XML ]); // Assume the client sent XML as the accept header, the following output will be // in XML form because it was the best match in the supported types (new \HTTP\Response())->withTypeNegotiation()->write("<p>Hello World</p>")->send();
统计信息
- 总下载量: 28.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-21