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

IPC
in package

FinalYes

Length-prefixed JSON framing for the native FCGI-style worker pool.

Wire format (symmetric, parent <-> child): [4 bytes: uint32 big-endian length] [N bytes: JSON-encoded payload]

Sanity cap: 64 MB per frame — protects against runaway corrupted-length reads draining all memory.

Table of Contents

Constants

MAX_FRAME_BYTES  : mixed = 64 * 1024 * 1024
Hard ceiling on a single frame body size (bytes).

Methods

encodeFrame()  : string
Encode a payload as one length-prefixed JSON frame (header + body) without writing it, so a caller can push it through a non-blocking pipe itself.
readFrame()  : array<string|int, mixed>|null
Read one length-prefixed JSON frame.
writeFrame()  : void
Write a length-prefixed JSON frame to an open stream.
readExact()  : string|null
Read exactly $n bytes from a stream with timeout.

Constants

MAX_FRAME_BYTES

Hard ceiling on a single frame body size (bytes).

public mixed MAX_FRAME_BYTES = 64 * 1024 * 1024

Methods

encodeFrame()

Encode a payload as one length-prefixed JSON frame (header + body) without writing it, so a caller can push it through a non-blocking pipe itself.

public static encodeFrame(array<string|int, mixed> $payload) : string

Encoding falls back in steps rather than dropping the payload: a binary body is base64-encoded first (byte-exact round trip); any remaining invalid UTF-8 (a raw byte in a query string, cookie or header) is substituted with U+FFFD so the request still goes through. Only a payload that is unencodable for another reason (a resource, recursion) becomes the synthetic 500 frame.

Parameters
$payload : array<string|int, mixed>
Return values
string

readFrame()

Read one length-prefixed JSON frame.

public static readFrame(resource $fp[, float $timeout = 30.0 ]) : array<string|int, mixed>|null
Parameters
$fp : resource

Readable stream.

$timeout : float = 30.0

Max seconds to wait (default 30).

Return values
array<string|int, mixed>|null

writeFrame()

Write a length-prefixed JSON frame to an open stream.

public static writeFrame(resource $fp, array<string|int, mixed> $payload) : void
Parameters
$fp : resource

Writable stream.

$payload : array<string|int, mixed>

readExact()

Read exactly $n bytes from a stream with timeout.

private static readExact(resource $fp, positive-int $n[, float $timeout = 30.0 ]) : string|null
Parameters
$fp : resource
$n : positive-int
$timeout : float = 30.0

Max seconds to wait.

Return values
string|null
On this page