appserver-io/fastcgi

fastcgi客户端

v2.0.0 2018-02-06 13:43 UTC

This package is auto-updated.

Last update: 2024-08-27 06:57:57 UTC


README

Fork自 [https://github.com/CrunchPHP/fastcgi]

FastCGI客户端库

允许从PHP直接访问FastCGI服务器。

  • 子请求
  • 测试(以Web服务器的视角获取页面)
  • 后台任务

用法

准备

require __DIR__ . '/../vendor/autoload.php';
use Crunch\FastCGI\Client as FastCGI;

$fastCgi = new FastCGI('unix:///var/run/php5-fpm.socket', null);
// $fastCgi = new FastCGI('localhost', 9999);
$connection = $fastCgi->connect();

请求

$request = $connection->newRequest();
$request->parameters = array(
    'GATEWAY_INTERFACE' => 'FastCGI/1.0',
    'REQUEST_METHOD' => 'POST',
    'SCRIPT_FILENAME' => '/var/www/example.php',
    'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
    'CONTENT_LENGTH' => strlen('foo=bar')
);
$request->stdin = 'foo=bar';

单次请求和响应

$response = $connection->request($request);
echo $response->content;

后台(包括多路复用)

$connection->sendRequest($request);
// Many code
$response = $connection->receiveResponse($request);

需求

  • PHP => 5.3

贡献者

有关如何贡献的详细信息,请参阅CONTRIBUTING.md。

许可证

此库根据MIT许可证授权。有关详细信息,请参阅LICENSE文件。