hollodotme/fast-cgi-client
High-performance FastCGI client for PHP that talks directly to PHP-FPM (no web server needed). Send requests, set env vars and stdin, read stdout/stderr, and run scripts in parallel—useful for CLIs, workers, or custom application servers.
Content-Transfer-Encoding: base64 header from multipart block for filesmime_content_type(), if availablenull nor a resourcedocker-compose.yml with composer archives via .gitattributes.gitattributes file to exclude non-relevant files/directories from archives/releases installed by composer - [#58]bin/fcgiget in composer.json as it is a potential security issue (because bin/fcgiget accepts any
accessible fastCGI endpoint and may be exposed in some setups)AbstractRequest due to a final constructor. - [#56]
See also: [#55]newWithRequestContent to all request classes in order to simplify the use of the new request
content type composers.error_reporting=-1 for CI and tests in order to capture deprecation warningsPlease take notice of the backwards incompatible changes (BC breaks) documented below in the changelog of 3.0.0-alpha & 3.0.0-beta.
The socket conection parameter was moved from the Client's constructor to
Client#sendRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request) : ProvidesResponseData
andClient#sendAsyncRequest(ConfiguresSocketConnection $connection, ProvidesRequestData $request) : intin order to allow sending (equal) requests to different FastCGI servers using the same Client instance. - [#45]
Removed method ProvidesResponseData#getRequestId() : int and Response#getRequestId() : int respectively in order
to avoid confusion about the semantics of the term "request ID" and misusage by assuming it is a unique ID for each
request (which it is not). Also the first constructor parameter of the Response class was removed with this change.
Renamed all $requestId(s) parameters to $socketId(s) in order to reflect the correct semantics of the ID. - [#39]
Renamed method Client#getRequestIdsHavingResponse() : array<int>
to Client#getSocketIdsHavingResponse() : array<int> in order to reflect the correct semantics of the returned array
of IDs. - [#39]
stream_select returning false in case of a system call interrupt. - [#41]pm.max_children setting. - [#40]Method Response#getHeaders() : array will now return a two-dimensional array with grouped values to support
multi-value headers. Previous versions returned a one-dimensional key-value array.
# Previous versions
[
'Status' => 'HTTP/2 200 OK',
'Set-Cookie' => 'tasty_cookie=strawberry',
]
# Since 3.0.0-alpha
[
'Status' => [
'HTTP/2 200 OK',
],
'Set-Cookie' => [
'yummy_cookie=choco',
'tasty_cookie=strawberry',
],
]
Method Response#getHeader(string $headerKey) : array will now return an array containing all values for the given
header key to support multi-value headers. Previous versions returned the last value as a string.
echo $response->getHeader('Set-Cookie');
# Previous versions
'tasty_cookie=strawberry'
# Since 3.0.0-alpha
[
'yummy_cookie=choco',
'tasty_cookie=strawberry'
]
Method Response#getRawResponse() : string is no longer available and its usage must be replaced
with Response#getOutput(). The method was deprecated since version 2.6.0.
Response#getHeaderLine(string $headerKey) : string that returns all values, separated by comma, for the given
key. - [#35]Response#getHeader(string $headerKey) : array
and Response#getHeaderLine(string $headerKey) : string. - [#35]Response#getRawResponse() : string that was deprecated in version 2.6.0 in favour
of Response#getOutput() : string. - [#36]Two new methods to Response class - [#27]
Response#getOutput() which is identical to Response#getRawResponse() and will return the complete output from
the STDOUT stream of the response.Response#getError() which will return the complete output of the STDERR stream of the response.Second parameter $errorBuffer in tha pass through callback signature - [#27]
$callback = function( string $outputBuffer, string $errorBuffer ) {};
This parameter will contain the contents of the STDERR stream packets.
Response#getRawResponse() in favour of consistant naming. This method will be removed in v3.0.0 - [#27]ProcessManagerException that was introduced in v2.5.0 - [#27]
Please read this blog post why this (BC breaking)
change was necessary and how to handle server-sent errors now.bin/fcgiget to accept full URL paths and print STDOUT and STDERR outputNew ProcessManagerException in case the php-fpm responds with packages of type STDERR. This refers mainly to the
error Primary script unknown resp. the response File not found..
CI builds for PHP 7.3
20000 and was updated to 200000 as
recommended in the official PHP documentation. - [#20]php://input on worker side when client sends content larger than 65535 bytes - [#15]getHost() and getPort() with getSocketAddress() in
interface hollodotme\FastCGI\Interfaces\ConfiguresSocketConnection - [#9]unix:// must be omitted for the first parameter
of hollodotme\FastCGI\SocketConnections\UnixDomainSocketfsockopen() with stream_socket_client() for connecting to php-fpm. - [#9]addResponseCallbacks(callable ...$callbacks) to all request classes to enable response evaluation delegation
addFailureCallbacks(callable ...$callbacks) to all request classes to enable exception handling delegationreadResponse(int $requestId, ?int $timeoutMs = null) : ProvidesResponseData to read and retrieve a single
responsereadResponses(?int $imeoutMs = null, int ...$requestIds) : \Generator to read and yield multiple responsesreadReadyResponses(?int $imeoutMs = null) : \Generator to check for ready responses, read and yield themwaitForResponses(?int $timeout = null) to Client class for waiting for multiple responses and calling the
respective response callbacks - [#5]getRequestIdsHavingResponse() : array to enable reactive read of responses as they occurhasUnhandledResponses() : bool to check for outstanding responseshandleResponse(int $requestId, ?int $timeoutMs = null) to fetch a specific response and notify the respective
response callbackhandleResponses(?int $timeoutMs = null, int ...$requestIds) to fetch a specific responses and notify the
respective response callbackshandleReadyResponses(?int $timeoutMs = null) to check for ready responses, fetch them and notify the
respective response callbackswaitForResponse(int $requestId, ?int $timeoutMs = null) is not returning a response anymore, but will call
the response callbackreadResponse(int $requestId, ?int $timeoutMs = null): ProvidesResponseData if you want to get the response
directly.sendRequest and sendAsyncRequest expect to get an object of
interface hollodotme\FastCGI\Interfaces\ProvidesRequestData - [#5]sendRequest and waitForResponse now return an object of
interface hollodotme\FastCGI\Interfaces\ProvidesResponseData - [#2]GET, POST, PUT, PATCH and DELETE
in hollodotme\FastCGI\Constants\RequestMethod - [#5]HTTP/1.0 and HTTP/1.1 in hollodotme\FastCGI\Constants\ServerProtocol
hollodotme\FastCGI\Requests\GetRequesthollodotme\FastCGI\Requests\PostRequesthollodotme\FastCGI\Requests\PutRequesthollodotme\FastCGI\Requests\PatchRequesthollodotme\FastCGI\Requests\DeleteRequestClientEncoders\PacketEncoderSocketConnections\DefaultsBased on Pierrick Charron's PHP-FastCGI-Client:
ConfiguresSocketConnectionUnixDomainSocket and NetworkSocketFastCGIClientExceptionForbiddenException, ReadFailedException, TimeoutException, WriteFailedExceptionClient now expects a ConfiguresSocketConnection instanceClient->request() to Client->sendRequest()Client->async_request() to Client->sendAsyncRequest()Client->wait_for_response() to Client->waitForResponse()ClientClient (now part of the
socket connection)Client->getValues()How can I help you explore Laravel packages today?