poa / httpserver
基于POA洋葱圈模型的中间件,定义Http服务器的处理逻辑
0.1.1
2021-10-30 12:28 UTC
Requires
- php: >=7.4
- poa/middleware: ~0.1.0
- psr/http-message: *
- psr/log: *
This package is auto-updated.
Last update: 2024-09-29 06:08:42 UTC
README
基于POA洋葱圈模型的中间件,定义Http服务器的处理逻辑
作者
安装
{ "require": { "poa/httpserver": "~0.1" } }
composer update
或
composer install poa/httpserver
示例
use Poa\Http\Router\Router; use Poa\Http\Server\HandleExceptionMiddleware; use Poa\Http\Server\HttpApplication; use Poa\Http\Server\HttpContext; use Poa\Http\Server\HttpServerInterface; use Poa\Middleware\ElapsedTimeMiddleware; use Poa\Middleware\MiddlewareSystemInterface; class FpmHttpServer implements HttpServerInterface { protected MiddlewareSystemInterface $application; public function start() { $context = new HttpContext(null, null); $app = $this->application; $app($context); } public function stop() { // do nothing } public function delegateRequest(MiddlewareSystemInterface $application) { $this->application = $application; } } $app = new HttpApplication(); $app->use(new HandleExceptionMiddleware()) ->use(new ElapsedTimeMiddleware()) ->use(new Router()); $server = new FpmHttpServer(); $server->delegateRequest($app); $server->start();
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。