jsphp consists of three core layers:
-
PHPEngine:- Manages loaded extensions, core functions, constants, and classes.
- Computes configuration SHA1 hash based on active extensions and defines.
- Manages file watching via
chokidarand compilation caching.
-
PHPContext:- Manages per-request runtime state, environment variables, working directory, output buffers, and superglobals (
$_GET,$_POST,$_SERVER, etc.). - Executes compiled JS functions within its isolated scope.
- Manages per-request runtime state, environment variables, working directory, output buffers, and superglobals (
-
AST Parser, Optimizer & Transpiler:
- Parses PHP 8.5 code into an AST representation.
- Optimizes constant expressions and dead code branches.
- Transpiles AST nodes into JS functions taking a
PHPContextargument.