HarvTTP PHP 8.5

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

PathFunction
ports/php85/sapi/harvos/php_harvos_sapi.cHarvOS SAPI for PHP/Zend: request startup, output, headers, POST, cookies, server variables and stream execution.
ports/php85/sapi/harvos/php_harvos_sapi.hRequest/response ABI used by HarvTTP.
ports/php85/sapi/harvos/php_harvos_compat.cCompatibility layer for libc, networking callbacks, mmap arena, filesystem and diagnostics.
ports/php85/sapi/harvos/config.m4PHP build-system integration.
ports/php85/modules/wordpress-recommended.txtModule profile for WordPress-oriented builds.
scripts/build_php85_harvos_wsl.ps1Builds the static PHP 8.5 library for HarvOS through WSL.
scripts/build_harvttp_php85_wsl.ps1Links HarvTTP against the PHP library and stages WordPress files into the data web root.

SAPI request flow

  1. HarvTTP resolves a .php path from the bundle or data web root.
  2. An HTTP worker claims a queued harvttp_http_job_t.
  3. The worker copies the PHP source into a bounded source buffer.
  4. HarvTTP builds a harvos_php85_request_t with script names, URI, query string, method, content type, cookies, POST bytes, client/server addresses and response buffers.
  5. The SAPI activates the worker's cooperative TSRM/ZTS context.
  6. Zend compiles and executes the script from a memory-backed stream.
  7. 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.

ConstantValueMeaning
HARVTTP_HTTP_WORKER_COUNT4PHP-capable HTTP workers.
HARVTTP_HTTP_JOB_COUNT8Bounded pending request slots.
HARVTTP_PHP_OUTPUT_MAX256 KiBMaximum buffered PHP response per job.
HARVTTP_FILE_MAX1 MiBMaximum loaded PHP source file.
HARVTTP_PHP_SQL_SOCKET_COUNT4Loopback 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=0 and enable_dl=0.
  • open_basedir limits PHP to /data/harvttp/webroot and /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.