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

FcgiCoroutineTransport
in package
implements FcgiTransport

FinalYes

Coroutine-yielding FastCGI transport (#289) — OpenSwoole\Coroutine\Client.

Every send() / recv() yields under the OpenSwoole event loop, so the worker is never blocked. Used ONLY when the dispatch already runs inside a coroutine (Coroutine::getCid() >= 0) — e.g. an fcgi backend reached from a coroutine-mode request. Outside a coroutine, FcgiBlockingTransport is used instead (the coroutine client cannot even be constructed at getCid() < 0).

Table of Contents

Interfaces

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

Properties

$buffer  : string
Read-ahead buffer. OpenSwoole\Coroutine\Client::recv() returns ALL available bytes (its argument is a timeout, not a length), so a small fast response arrives in one segment. The FCGI framing reads EXACT lengths (8-byte header, then content), so we buffer what recv() returns and hand back at most the requested count — otherwise recvExact(8) for the header would swallow the whole response and the body would be lost (#289).
$conn  : Client|null
$host  : string
$isUnix  : bool
$port  : int
$timeout  : float

Methods

__construct()  : mixed
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.

Properties

$buffer

Read-ahead buffer. OpenSwoole\Coroutine\Client::recv() returns ALL available bytes (its argument is a timeout, not a length), so a small fast response arrives in one segment. The FCGI framing reads EXACT lengths (8-byte header, then content), so we buffer what recv() returns and hand back at most the requested count — otherwise recvExact(8) for the header would swallow the whole response and the body would be lost (#289).

private string $buffer = ''

Methods

__construct()

public __construct(string $host, int $port, bool $isUnix, float $timeout) : mixed
Parameters
$host : string
$port : int
$isUnix : bool
$timeout : float

recv()

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

public recv(int $maxLen) : string
Parameters
$maxLen : int
Return values
string

send()

Send all bytes to the backend.

public send(string $data) : void
Parameters
$data : string
On this page