xiaodi / think-psr7
PSR-7 消息实现,同时也提供了常用实用方法
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);