garveen / fastcgi
有效的 FastCGI 到 psr-7 适配器
0.1.2
2017-03-12 20:17 UTC
Requires
- guzzlehttp/psr7: ^1.3
- psr/http-message: ^1.0
This package is not auto-updated.
Last update: 2024-09-15 00:49:48 UTC
README
这个库是一个有效的 FastCGI
到 PSR-7
适配器。
安装
composer require garveen/fastcgi
用法
use Garveen\FastCgi\FastCgi; use Psr\Http\Message\ServerRequestInterface; // First of all, define 3 callbacks // When a request is ready, this library will call $requestCallback: $requestCallback = function (ServerRequestInterface $serverRequest) { // Do something... // And the response must be instance of Psr\Http\Message\ResponseInterface // This library provides Garveen\FastCgi\Response return new Response; }; // After this library got the response, $sendCallback will be called: $sendCallback = function (int $fd, string $data) { // send $data to downstream fwrite($downstreams[$fd], $data); }; // At the end, if keepalive is not set, there will be $closeCallback: $closeCallback = function (int $fd) { fclose($downstreams[$fd]); }; // The instance $fastcgi = new FastCgi($requestCallback, $sendCallback, $closeCallback, $logger); // Once you have recevied a FastCGI network-package, just pass it to the instance: $fastcgi->receive(int $fd, string $data);