API Index — Namespaces, Packages, Reports, Indices
API Documentation
Table of Contents
Namespaces
Classes
- ZealPHP_IPC_Sender
- Destructor-based metadata frame sender. PHP runs destructors even after
exit()is called from inside a shutdown function — phpMyAdmin'sResponseRenderer->response()does exactly that. The shutdown chain gets preempted, but a destructor on a static instance still fires, so the parent receives status/headers/cookies regardless of how the request ended.
Constants
- SID : mixed = ''
Functions
- apache_request_headers() : array<string, string>
- Return all HTTP request headers as an associative array.
- getallheaders() : array<string, string>
- Alias for
apache_request_headers()— both names exist under mod_php. - apache_response_headers() : array<string, string>
- Return all response headers queued for the current request.
- apache_setenv() : bool
- Set a named Apache subprocess environment variable.
- apache_getenv() : string|false
- Retrieve a named Apache subprocess environment variable.
- apache_note() : string
- Get or set an Apache request note (named annotation attached to the request).
- virtual() : bool
- Perform an Apache internal sub-request for
$uri. - __z_fire_header_callback() : void
- #357 — fire a registered header_register_callback() exactly once (mod_php keeps a single callback). Two registration sources, drained in order: (1) the subprocess-local override above, which stashes into $GLOBALS['__z_header_callback'] (the common case — autoload off); (2) the framework's utils.php header_register_callback(), active when ZEALPHP_CGI_AUTOLOAD=1, which stashes into the RequestContext memo.
- __z_send_meta() : mixed
- Write the metadata frame (status, headers, cookies, optional return value) to
STDERRas a single JSON line. Idempotent — subsequent calls are no-ops once$__z_meta_sentistrue. Called by theflush()override and the shutdown function so the frame is always sent before the body, regardless of whether the included file streams or buffers. - apache_request_headers() : array<string, string>
- Polyfill for
apache_request_headers()in CLI SAPI. - getallheaders() : array<string, string>
- Polyfill for
getallheaders()in CLI SAPI — delegates toapache_request_headers(). - apache_response_headers() : array<string, string>
- Polyfill for
apache_response_headers()in CLI SAPI. - apache_setenv() : bool
- Polyfill for
apache_setenv()in CLI SAPI. - apache_getenv() : mixed
- Polyfill for
apache_getenv()in CLI SAPI. - apache_note() : string
- Polyfill for
apache_note()in CLI SAPI. - virtual() : bool
- Polyfill for
virtual()in CLI SAPI. - fork_prepare_request() : string|null
- Populate request superglobals + php://input from a request frame. Returns the absolute file to include, or null on a bad/missing file. (The include itself is done by the CALLER at top-level scope — see the loop — so the included file's top-level variables become real $GLOBALS.)
- fork_build_response() : array<string, mixed>
- Build the response frame from the captured state + the include's output.
-
pool_prepare_request()
: array{file: string, prevCwd: mixed}|array{__error: array
} - Prepare per-request state and return the file to include + the prior cwd.
- pool_finish_request() : array<string, mixed>
- Capture output and build the response AFTER the global-scope include.
- pool_reset_request_state() : void
- Reset all per-request state between pool iterations.
Constants
SID
public
mixed
SID
= ''
Functions
apache_request_headers()
Return all HTTP request headers as an associative array.
apache_request_headers() : array<string, string>
Shim for apache_request_headers() / getallheaders() on non-Apache SAPIs.
Return values
array<string, string>getallheaders()
Alias for apache_request_headers() — both names exist under mod_php.
getallheaders() : array<string, string>
This shim makes getallheaders() available on OpenSwoole / CLI SAPIs.
Return values
array<string, string>apache_response_headers()
Return all response headers queued for the current request.
apache_response_headers() : array<string, string>
Delegates to \ZealPHP\apache_response_headers() which reads from the
per-request $g->zealphp_response header list.
Return values
array<string, string>apache_setenv()
Set a named Apache subprocess environment variable.
apache_setenv(string $variable, string $value[, bool $walk_to_top = false ]) : bool
In ZealPHP this writes into the per-request $g->server bag under the
conventional HTTP_* key so subsequent handler code sees the value.
The $walk_to_top parameter is accepted for API compatibility but has
no effect (there is no parent-request scope in OpenSwoole).
Parameters
- $variable : string
- $value : string
- $walk_to_top : bool = false
Return values
boolapache_getenv()
Retrieve a named Apache subprocess environment variable.
apache_getenv(string $variable[, bool $walk_to_top = false ]) : string|false
Returns false when the variable is not set (matching Apache's behaviour).
The $walk_to_top parameter is accepted for API compatibility but has
no effect in ZealPHP.
Parameters
- $variable : string
- $walk_to_top : bool = false
Return values
string|falseapache_note()
Get or set an Apache request note (named annotation attached to the request).
apache_note(string $note_name[, string|null $note_value = null ]) : string
When $note_value is null, returns the current value of the note.
When $note_value is provided, sets it and returns the previous value (or
an empty string when the note was not previously set).
Parameters
- $note_name : string
- $note_value : string|null = null
Return values
stringvirtual()
Perform an Apache internal sub-request for $uri.
virtual(string $uri) : bool
In ZealPHP this dispatches the URI through the framework's routing stack
in-process (similar to Apache's virtual() / mod_include sub-request
mechanism). Returns true on success, false on failure.
Parameters
- $uri : string
Return values
bool__z_fire_header_callback()
#357 — fire a registered header_register_callback() exactly once (mod_php keeps a single callback). Two registration sources, drained in order: (1) the subprocess-local override above, which stashes into $GLOBALS['__z_header_callback'] (the common case — autoload off); (2) the framework's utils.php header_register_callback(), active when ZEALPHP_CGI_AUTOLOAD=1, which stashes into the RequestContext memo.
__z_fire_header_callback() : void
MUST be called while the header() override is still active (right after the included file finishes) — NOT from the shutdown function: uopz tears its overrides down before register_shutdown_function runs, so header() calls inside a callback fired at shutdown would not be captured into $__z_headers.
__z_send_meta()
Write the metadata frame (status, headers, cookies, optional return value) to STDERR
as a single JSON line. Idempotent — subsequent calls are no-ops once $__z_meta_sent
is true. Called by the flush() override and the shutdown function so the frame is
always sent before the body, regardless of whether the included file streams or buffers.
__z_send_meta() : mixed
apache_request_headers()
Polyfill for apache_request_headers() in CLI SAPI.
apache_request_headers() : array<string, string>
Reconstructs the canonical header map from $_SERVER HTTP_* keys plus
CONTENT_TYPE and CONTENT_LENGTH, matching Apache mod_php behaviour.
Return values
array<string, string> —Map of header name → value.
getallheaders()
Polyfill for getallheaders() in CLI SAPI — delegates to apache_request_headers().
getallheaders() : array<string, string>
Return values
array<string, string> —Map of header name → value.
apache_response_headers()
Polyfill for apache_response_headers() in CLI SAPI.
apache_response_headers() : array<string, string>
Returns the response headers collected so far by the header() override.
Return values
array<string, string> —Map of header name → value.
apache_setenv()
Polyfill for apache_setenv() in CLI SAPI.
apache_setenv(string $variable, string $value[, bool $walk_to_top = false ]) : bool
Stores $value in the subprocess-local $__z_apache_env map (Apache mod_env parity).
Parameters
- $variable : string
- $value : string
- $walk_to_top : bool = false
Return values
boolapache_getenv()
Polyfill for apache_getenv() in CLI SAPI.
apache_getenv(string $variable[, bool $walk_to_top = false ]) : mixed
Reads from $__z_apache_env; returns false when the variable is not set.
Parameters
- $variable : string
- $walk_to_top : bool = false
apache_note()
Polyfill for apache_note() in CLI SAPI.
apache_note(string $note_name[, string|null $note_value = null ]) : string
Gets/sets a named note in $__z_apache_notes. Returns the previous value (empty string if unset).
Parameters
- $note_name : string
- $note_value : string|null = null
Return values
stringvirtual()
Polyfill for virtual() in CLI SAPI.
virtual(string $uri) : bool
Internal sub-requests are not supported in the subprocess context — always returns false.
Parameters
- $uri : string
Return values
boolfork_prepare_request()
Populate request superglobals + php://input from a request frame. Returns the absolute file to include, or null on a bad/missing file. (The include itself is done by the CALLER at top-level scope — see the loop — so the included file's top-level variables become real $GLOBALS.)
fork_prepare_request(array<string|int, mixed> $req) : string|null
Parameters
- $req : array<string|int, mixed>
Return values
string|nullfork_build_response()
Build the response frame from the captured state + the include's output.
fork_build_response(mixed $result, string $body) : array<string, mixed>
Parameters
- $result : mixed
-
the include's return value
- $body : string
Return values
array<string, mixed>pool_prepare_request()
Prepare per-request state and return the file to include + the prior cwd.
pool_prepare_request(array<string|int, mixed> $req) : array{file: string, prevCwd: mixed}|array{__error: array}
The include itself is performed by the CALLER at GLOBAL scope (see the
request loop) — NOT here — so a legacy app's top-level variables
($menu / $submenu in WP's wp-admin) become real $GLOBALS. Including from
inside a function made them function-locals, so WP's global $menu resolved
to null and uksort($menu, …) fataled. [Issue 1: include scope]
Parameters
- $req : array<string|int, mixed>
Return values
array{file: string, prevCwd: mixed}|array{__error: arraypool_finish_request()
Capture output and build the response AFTER the global-scope include.
pool_finish_request(mixed $result, Throwable|null $error, mixed $prevCwd) : array<string, mixed>
Parameters
- $result : mixed
-
the include's return value (null if it threw)
- $error : Throwable|null
-
exception thrown by the include, if any
- $prevCwd : mixed
-
cwd to restore
Return values
array<string, mixed>pool_reset_request_state()
Reset all per-request state between pool iterations.
pool_reset_request_state() : void
Clears superglobals ($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES,
$_REQUEST, $_SESSION), the raw input buffer, response capture state
($__pw_headers, $__pw_cookies, $__pw_rawcookies, $__pw_status),
any queued shutdown functions, and all output buffers.
Performs FPM-style $GLOBALS cleanup (unsets request-scope keys not in
the boot snapshot) and, when ext-zealphp is loaded, calls
zealphp_process_state_clean() to roll back constants, classes, functions,
and included files to the boot baseline.
When ZEALPHP_POOL_FULL_RESET=1 is set, also resets op_array
run_time_cache, function-local statics, and class static properties
(mirrors CoSessionManager's per-request reset stack from ext-zealphp 0.3.25).
IMPORTANT: Must be called at GLOBAL SCOPE (not inside a function) so that
$_SESSION = null and the superglobal resets take effect process-wide.