PHP code example of xiaodi / think-psr7
1. Go to this page and download the library: Download xiaodi/think-psr7 library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xiaodi / think-psr7 example snippets
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));
});
namespace think;
用并响应
$http = (new App())->http;
$response = $http->run();
// 已失效
$response->send();
// 已失效
$http->end($response);