PHP FastCGI Client

其他类别 2025-08-23

PHP FastCGI Client

PHP FastCGI Client是用于PHP的轻量级单文件FastCGI客户端。

我该如何使用它?

 

require ' vendor/autoload.php ' ;

use Adoy  FastCGI  Client ;

// Existing socket, such as Lighttpd with mod_fastcgi:
$ client = new Client ( ' unix:///path/to/php/socket ' , - 1 );

// Fastcgi server, such as PHP-FPM:
$ client = new Client ( ' localhost ' , ' 9000 ' );
$ content = ' key=value ' ;
echo $ client -> request (
	array (
		' GATEWAY_INTERFACE ' => ' FastCGI/1.0 ' ,
		' REQUEST_METHOD ' => ' POST ' ,
		' SCRIPT_FILENAME ' => ' test.php ' ,
		' SERVER_SOFTWARE ' => ' php/fcgiclient ' ,
		' REMOTE_ADDR ' => ' 127.0.0.1 ' ,
		' REMOTE_PORT ' => ' 9985 ' ,
		' SERVER_ADDR ' => ' 127.0.0.1 ' ,
		' SERVER_PORT ' => ' 80 ' ,
		' SERVER_NAME ' => ' mag-tured ' ,
		' SERVER_PROTOCOL ' => ' HTTP/1.1 ' ,
		' CONTENT_TYPE ' => ' application/x-www-form-urlencoded ' ,
		' CONTENT_LENGTH ' => strlen ( $ content )
	),
	$ content
);

命令行工具

通过网络套接字进行呼叫:

 ./fcgiget.php localhost:9000/status

通过UNIX域插座运行呼叫

 ./fcgiget.php unix:/var/run/php-fpm/web.sock/status

注意:为调试目的提供此命令行工具。

作者

  • Pierrick Charron (Pierrick@php.net) - 初始工作
  • 雷米·毛利

执照

该项目是根据麻省理工学院许可证获得许可的 - 有关完整的版权和许可信息,请查看使用此源代码分发的许可证文件。


版权所有2010-2019 Pierrick Charron Inc.保留所有权利。

下载源码

通过命令行克隆项目:

git clone https://github.com/adoy/PHP-FastCGI-Client.git