Xao / Technical Fieldnotes

Operations & Runtime · Issue 1.0.0-dev · 2 min read

PHC Runtime & Compatibility

Running Xao on PHC in isolate and worker modes, sandbox defaults, worker-safe autoloading, and P00–P05 compatibility findings.

Audience: Operators and PHC contributorsWords: 368Source: content/phc-runtime.md
Open library index (12 documents)

Xao is verified continuously against PHC (phc check, phc run, and phc serve in both isolate and worker modes) alongside PHP 8.4 parity checks.

Summary of PHC Capabilities & Workarounds

AreaStatusNotes
Worker-mode closure autoloaderWorkaround in placesrc/autoload.php registers a named global function xao_autoload() guarded by function_exists() rather than an anonymous closure
DOMDocument & namespace-aware DOMResolved in PHC P11 (xot)Supports createElementNS, getElementsByTagNameNS, importNode, C14N
DOMXPath queries & predicatesResolved in PHC P11 (xee-xpath)Supports query(), evaluate(), registerNamespace(), axes, predicates
xml:space="preserve" text nodesResolved in PHC (xml.rs)Preserves leading/trailing spaces inside <text xml:space="preserve">
Native XSLT 3.0 (xsl3)Default build (P10)XSLTProcessor in-process via pure-Rust xee-xslt/xot
CommonMark XML 1.0 (markdown-xml)Default build (P12)phc_markdown_to_xml() / phc_markdown_to_dom() via comrak
LIBXML_NONET constantGuarded in DomDocChecked with defined('LIBXML_NONET') at runtime

Sandbox Defaults (phc.toml)

PHC executes request handlers inside a deny-by-default sandbox:

  • allow_network = false by default: Because PhcNativeXsltDriver runs in-process, Xao and XaoDocs need zero network egress. Set allow_network = true only when using SaxonHttpDriver or fetching remote HTTP APIs.

  • allowed_roots: Explicitly list every directory accessed by the app (for example ["public", "src", "stylesheets", "data"], or ["public", "src", "content", "themes", "../../Xao/src"] in XaoDocs).

  • allow_file_databases: Enable only when using file-backed SQLite databases via PDO.

  • Relative paths in PHP: Always anchor filesystem paths to dirname(__DIR__) rather than getcwd(), which can differ between CLI (phc run), isolate, and worker modes.

xee-xslt Authoring Notes

When authoring stylesheets for PhcNativeXsltDriver (xee-xslt):

  • Prefer <xsl:apply-templates select="..." mode="..."/> over <xsl:call-template> (unsupported in current xee-xslt).

  • Prefer XPath 3.1 sibling grouping (following-sibling::*[preceding-sibling::cm:heading[@level='2'][1] is $h]) over <xsl:for-each-group>.

  • Declare <xsl:variable> bindings before any literal result elements in the same enclosing block, and format numbers with XPath expressions rather than <xsl:number> or format-number().

  • Use expand-text="yes", xsl:include, xsl:import, xsl:output method="html", xsl:param, xsl:element, xsl:attribute, and priority="2" overrides freely.