Alpha ZealPHP is early-stage and under active development. APIs may change between minor versions until v1.0. Feedback and bug reports welcome on GitHub.
API Index — Namespaces, Packages, Reports, Indices

FcgiTransport
in

Socket transport for {@see FastCgiClient} (#289).

The FastCGI protocol framing in FastCgiClient is transport-agnostic — only three operations touch the socket: connect, send, and receive. This interface abstracts those three so the client can run over EITHER:

  • FcgiCoroutineTransportOpenSwoole\Coroutine\Client; yields under the event loop. Used when already inside a coroutine (getCid() >= 0).
  • FcgiBlockingTransport — plain stream_socket_client with blocking fread/fwrite. Used when OUTSIDE a coroutine (getCid() < 0), e.g. the legacy-cgi / superglobals(true) lifecycles where the request handler is NOT coroutine-wrapped.

Why this exists: #261 fixed an "API must be called in the coroutine" fatal by wrapping the coroutine client in Coroutine::run() when outside a coroutine. But that nests a fresh scheduler INSIDE the OpenSwoole reactor callback — the reactor is parked waiting for the scheduler, which needs the reactor to deliver the socket-readable event, so the FCGI read never completes and every request HANGS until cgi_timeout (#289). A blocking socket has no scheduler to deadlock, which is the semantically correct behaviour for the synchronous, one-request-at- a-time legacy-cgi worker.

Table of Contents

Methods

close()  : void
Close the connection (idempotent).
connect()  : void
Open the connection to the FastCGI backend.
recv()  : string
Receive up to $maxLen bytes. Returns '' on a clean EOF (peer closed).
send()  : void
Send all bytes to the backend.

Methods

close()

Close the connection (idempotent).

public close() : void

recv()

Receive up to $maxLen bytes. Returns '' on a clean EOF (peer closed).

public recv(int $maxLen) : string
Parameters
$maxLen : int
Tags
throws
FastCgiException

on a hard socket error or timeout.

Return values
string

send()

Send all bytes to the backend.

public send(string $data) : void
Parameters
$data : string
Tags
throws
FastCgiException

on a write error.

On this page