codejet / http
PSR7 http消息实现
0.0.1
2016-12-30 17:14 UTC
Requires
- php: ^7.0
- psr/http-message: ^1.0
Requires (Dev)
- http-interop/http-factory-tests: ^0.2
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-08-29 04:40:25 UTC
README
这是一个正在进行中的工作。
这是一个理解http-interop相关标准的练习,并且是对PSR-7 HTTP消息接口和HTTP-Factory接口的实现。
安装
通过Composer
$ composer require codejet/http
用法
Uri
直接使用Uri类。
$uri = new CodeJet\Http\Uri('https://www.example.com'); echo $uri;
或者,使用http-interop提议的工厂。
$uri = new CodeJet\Http\Factory\UriFactory('https://www.example.com'); echo $uri;
请求
使用PSR7 RequestInterface方法创建请求。
$request = (new CodeJet\Http\Request())->withMethod('POST')->withUri($uri); echo $uri;
流
使用类构造函数。
$handle = fopen('php://input','r'); $stream = new CodeJet\Http\Stream($handle);
或者,使用http-interop提议的StreamFactory。
从字符串
$string = "I love lamp."; $stream = (new CodeJet\Http\Factory\StreamFactory())->createStream($string);
从文件
$stream = (new CodeJet\Http\Factory\StreamFactory())->createStreamFromFile('php://input', 'r');
从资源句柄
$handle = fopen('php://input','r'); $stream = (new CodeJet\Http\Factory\StreamFactory())->createStreamFromResource($handle);
变更日志
请查看CHANGELOG获取最近更改的详细信息。
测试
$ composer test
贡献
请查看CONTRIBUTING获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过josh@findsomehelp.com发送电子邮件,而不是使用问题跟踪器。
许可
MIT许可(MIT)。请查看许可文件获取更多信息。