vaibhavpandeyvpz / sandesh
PSR-7 和 PSR-17 实现,与 PHP >= 5.3 兼容。
2.0.2
2020-04-23 11:12 UTC
Requires
- php: ^7.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0
Provides
README
PSR-7 和 PSR-17 实现,与 PHP >= 7.0 兼容。
Sandesh:
संदेश
(信息)
安装
composer require vaibhavpandeyvpz/sandesh
用法
<?php /** * @desc Creates an instance of Psr\Http\Message\RequestInterface. */ $request = (new Sandesh\RequestFactory()) ->createRequest('POST', 'https://api.example.com/user/save'); /** * @desc Creates an instance of Psr\Http\Message\ServerRequestInterface. */ $request = (new Sandesh\ServerRequestFactory()) ->createServerRequest('POST', 'https://api.example.com/user/save', $_SERVER); /** * @desc Creates an instance of Psr\Http\Message\ResponseInterface. */ $response = (new Sandesh\ResponseFactory()) ->createResponse(404); /** * @desc Creates an instance of Psr\Http\Message\StreamInterface. */ $stream = (new Sandesh\StreamFactory()) ->createStream(); // or $stream = (new Sandesh\StreamFactory()) ->createStreamFromFile('/path/to/file'); // or $stream = (new Sandesh\StreamFactory()) ->createStreamFromResource(fopen('php://input', 'r')); /** * @desc Creates an instance of Psr\Http\Message\UploadedFileInterface. */ $stream = (new Sandesh\StreamFactory()) ->createStreamFromFile($_FILES[0]['tmp_name']); $request = (new Sandesh\UploadedFileFactory()) ->createUploadedFile( $stream, $_FILES[0]['size'], $_FILES[0]['error'], $_FILES[0]['name'], $_FILES[0]['type']); /** * @desc Creates an instance of Psr\Http\Message\UriInterface. */ $uri = (new Sandesh\UriFactory()) ->createUri('http://domain.tld:9090/subdir?test=true#phpunit');
额外功能
<?php /** * @desc Parse Set-Cookie header(s) and create an instance of Sandesh\CookieInterface. */ $cookie = (new Sandesh\CookieFactory()) ->createCookie('PHPSESS=1234567890; Domain=domain.tld; Expires=Wed, 21 Oct 2015 07:28:00 GMT; HttpOnly; Max-Age=86400; Path=/admin; Secure'); /** * @desc After making changes you can just cast it to a RFC-6265 valid string as show below. */ $header = (string)$cookie;
文档
要查看详细说明,请访问 Wiki。
许可证
请参阅 LICENSE 文件。