A PHP fast CGI client to send requests (a)synchronously to PHP-FPM using the FastCGI Protocol.
This library is based on the work of Pierrick Charron's PHP-FastCGI-Client and was ported and modernized to latest PHP versions, extended with some features for handling multiple requests (in loops) and unit and integration tests as well.
The full documentation is available at fast-cgi-client.hollo.me.
- What it is
- Installation
- Getting started
- Use cases & examples — connections, single requests, multiple requests, requests, responses, exceptions, trouble shooting
- API reference
This is version 4.x, which requires PHP >= 8.0.
Please have a look at the backwards incompatible changes (BC breaks) in the changelog, if you upgrade from a previous version.
| Version | PHP | Documentation | Changelog |
|---|---|---|---|
| 4.x | >= 8.0 | 4.x | CHANGELOG.md |
| 3.x | >= 7.1 | 3.x | 3.x |
| 2.x | >= 7.1 | 2.x | 2.x |
| 1.x | >= 7.0 | 1.x | 1.x |
Version 3.x still gets bug fixes, but no new features.
composer require hollodotme/fast-cgi-client<?php declare(strict_types=1);
use hollodotme\FastCGI\Client;
use hollodotme\FastCGI\RequestContents\UrlEncodedFormData;
use hollodotme\FastCGI\Requests\PostRequest;
use hollodotme\FastCGI\SocketConnections\NetworkSocket;
$client = new Client();
$connection = new NetworkSocket( '127.0.0.1', 9000 );
$request = new PostRequest( '/path/to/target/script.php', new UrlEncodedFormData( ['key' => 'value'] ) );
$response = $client->sendRequest( $connection, $request );
echo $response->getBody();Sending requests asynchronously, reacting to responses with callbacks, streaming output and much more is described in the documentation.
Contributions are welcome, please read the contribution guide. It also describes how to run the tests, the static analysis and the documentation website locally.
The FastCGI Client is released under the MIT License.