PHP 8.5 through the Zend engine
HarvTTP's PHP path is no longer described as a template substitute. The HarvOS SAPI is written against PHP/Zend's normal SAPI APIs and is the boundary used to execute PHP source from HarvTTP request buffers.
Port files
| Path | Function |
|---|---|
ports/php85/sapi/harvos/php_harvos_sapi.c | HarvOS SAPI for PHP/Zend: request startup, output, headers, POST, cookies, server variables and stream execution. |
ports/php85/sapi/harvos/php_harvos_sapi.h | Request/response ABI used by HarvTTP. |
ports/php85/sapi/harvos/php_harvos_compat.c | Compatibility layer for libc, networking callbacks, mmap arena, filesystem and diagnostics. |
ports/php85/sapi/harvos/config.m4 | PHP build-system integration. |
ports/php85/modules/wordpress-recommended.txt | Module profile for WordPress-oriented builds. |
scripts/build_php85_harvos_wsl.ps1 | Builds the static PHP 8.5 library for HarvOS through WSL. |
scripts/build_harvttp_php85_wsl.ps1 | Links HarvTTP against the PHP library and stages WordPress files into the data web root. |
SAPI request flow
- HarvTTP resolves a
.phppath from the bundle or data web root. - An HTTP worker claims a queued
harvttp_http_job_t. - The worker copies the PHP source into a bounded source buffer.
- HarvTTP builds a
harvos_php85_request_twith script names, URI, query string, method, content type, cookies, POST bytes, client/server addresses and response buffers. - The SAPI activates the worker's cooperative TSRM/ZTS context.
- Zend compiles and executes the script from a memory-backed stream.
- Headers and output are copied back to HarvTTP and sent through HNET.
Concurrent PHP workers
HarvTTP currently has four HTTP worker slots and eight queued PHP jobs. The PHP build enables ZTS, while the HarvOS patches replace pthread TLS with cooperative thread IDs and saved TSRM caches. That allows independent HarvTTP workers to keep separate PHP request state without pretending that the current bare-metal scheduler is a full preemptive OS.
| Constant | Value | Meaning |
|---|---|---|
HARVTTP_HTTP_WORKER_COUNT | 4 | PHP-capable HTTP workers. |
HARVTTP_HTTP_JOB_COUNT | 8 | Bounded pending request slots. |
HARVTTP_PHP_OUTPUT_MAX | 256 KiB | Maximum buffered PHP response per job. |
HARVTTP_FILE_MAX | 1 MiB | Maximum loaded PHP source file. |
HARVTTP_PHP_SQL_SOCKET_COUNT | 4 | Loopback SQL sockets exposed to PHP. |
Build commands
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_php85_harvos_wsl.ps1 -ModuleProfile wordpress-recommended
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_harvttp_php85_wsl.ps1 -SkipPhp85Build
The WordPress profile includes the core modules WordPress commonly
expects, including mysqli, mysqlnd,
mbstring, curl, dom,
fileinfo, gd, intl,
json, openssl, session,
simplexml, tokenizer, xml,
zip and zlib.
WordPress path
The PHP-enabled build can copy a full WordPress source tree into
release/data_usb/data/harvttp/webroot. It also stages a
fast overlay for practical diagnostics and login testing. Full
wp-full.php bootstrap remains the heaviest current path
because it exercises PHP startup, file traversal, OPcache metadata,
SQL access and long-running response streaming at the same time.
$env:HARVOS_WORDPRESS_SOURCE = "C:\Users\dennis\Downloads\wordpress"
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_harvttp_php85_wsl.ps1 -SkipPhp85Build
SQL integration
The SAPI exposes networking callbacks in harvos_php85_request_t.
The compatibility layer maps MySQL client traffic onto HarvTTP's
loopback SQL sockets, and HarvSQL answers on the MySQL-compatible port.
This is the path intended for WordPress database access through
mysqli and mysqlnd.
Memory and OPcache settings
PHP expects facilities that are large compared with the original tiny HTTP demo. The HarvOS build reduces OPcache defaults, disables the JIT, uses a bounded mmap arena and pumps the HarvTTP host/network loop during long Zend persistence work so the server can keep sending progress data instead of appearing dead.
Security profile
expose_php=0,allow_url_include=0andenable_dl=0.open_basedirlimits PHP to/data/harvttp/webrootand/data/harvttp.- Shell, process and mail functions are disabled by default.
- The current profile is hardening, not a complete sandbox; final isolation belongs in the HarvOS supervisor, MMU/MPU policy and per-task heap model.
Remaining runtime risks
- Long WordPress requests can still dominate the cooperative scheduler when Zend work does not yield often enough.
- The current SQL layer is intentionally small and does not implement the full MySQL server feature set.
- Large PHP source files and large responses hit fixed buffers by design.
- The HNET device still needs supervisor-level multiplexing before independent HarvTTP and HarvSQL ELFs can own the NIC concurrently.