xiaodi / think-psr7
PSR-7 message implementation that also provides common utility methods
v2.7.7
2021-02-23 06:45 UTC
Requires
- php: ^7.2
- laminas/laminas-httphandlerrunner: ^1.2
- psr/http-factory: ^1.0
- psr/http-message: ~1.0
- ralouphie/getallheaders: ^2.0.5 || ^3.0.0
Requires (Dev)
- http-interop/http-factory-tests: dev-master
- phpunit/phpunit: ^8.5
Suggests
- laminas/laminas-httphandlerrunner: Emit PSR-7 responses
Provides
README
use think\Psr7\HttpHandlerRunner; use think\Psr7\ServerRequest; use think\Psr7\Response; Route::get('/hello', function (ServerRequest $req, Response $response) { $response->getBody()->write('Hello World!'); return HttpHandlerRunner::make($response->withStatus(200)); });
注意
如使用 HttpHandlerRunner::make()
返回 response 信息, public/index.php
入口文件以下代码将会失效
此文件代为处理
中间件 end 方法 暂时失效
namespace think;
require __DIR__ . '/../vendor/autoload.php';
// 执行HTTP应用并响应
$http = (new App())->http;
$response = $http->run();
// 已失效
$response->send();
// 已失效
$http->end($response);