<?xml version="1.0" encoding="UTF-8"?>
<xao-docs>
  <site name="XaoDocs" product="Xao" version="1.0.0-dev" homepage="https://xao.ndx.au" repo="https://github.com/ndx-au/Xao" examples-repo="https://github.com/ndx-au/xao-example-apps"/>
  <request slug="phc-runtime" theme="atlas" path="/xml/phc-runtime" xml-url="/xml/phc-runtime"/>
  <themes>
    <theme id="atlas" name="Atlas" tagline="Three-column reference desk with persistent sidebar and sticky page outline" audience="API and framework developers browsing across sections" structure="3-column grid: left navigation sidebar, center article, right on-this-page outline" css="/assets/atlas.css" active="true"/>
    <theme id="folio" name="Folio" tagline="Editorial journal spread with XPath-grouped numbered chapters and collapsible library" audience="Architects and evaluators reading long-form conceptual chapters" structure="Editorial cover header, collapsible library drawer, and sibling-grouped numbered chapter sections" css="/assets/folio.css" active="false"/>
    <theme id="console" name="Console" tagline="Operations dashboard with telemetry strip and collapsible H2 module accordions" audience="SREs, operators, and runtime engineers scanning sections quickly" structure="Command header, telemetry bar, compact nav rail, and expandable &lt;details&gt; module accordions" css="/assets/console.css" active="false"/>
    <theme id="reader" name="Reader (A11y)" tagline="WCAG AAA single-column linear reader with upfront summary, numbered TOC, and zero JS" audience="Screen reader users, keyboard-only navigation, and low-vision / cognitive accessibility" structure="Multi-landmark skip links, upfront document summary, inline numbered TOC, figure-wrapped code blocks, directory after article, zero JS" css="/assets/reader.css" active="false"/>
    <theme id="handbook" name="Handbook" tagline="Single-column print-ready technical specification sheet with metadata ledger" audience="Technical reviewers, auditors, and print/PDF export workflows" structure="Single-column specification document with &lt;dl&gt; metadata ledger, numbered outline, and print stylesheet" css="/assets/handbook.css" active="false"/>
  </themes>
  <navigation>
    <section name="Start Here">
      <item slug="index" title="Xao Documentation" description="XML Application Objects for PHP 8 and PHC — zero-dependency XML content aggregation and XSLT 3.0 presentation." order="1" active="false"/>
      <item slug="getting-started" title="Getting Started" description="Set up PHC, autoload Xao with zero Composer packages, transform your first DomDoc with XSLT 3.0, and run phc serve." order="2" active="false"/>
    </section>
    <section name="Core Concepts">
      <item slug="architecture" title="Architecture &amp; XML Aggregation" description="How Xao builds a unified XML conglomeration document from databases, Markdown, and domain objects before delegating presentation to XSLT 3.0." order="3" active="false"/>
      <item slug="xslt-themes" title="XSLT 3.0 Themes vs CSS Skins" description="Why XSLT themes are structurally and semantically richer than CSS-only themes — including accessibility-first DOM transformations." order="4" active="false"/>
    </section>
    <section name="Framework Reference">
      <item slug="core-api" title="Core API Reference" description="Reference for Xao\\Runtime, Xao\\XaoRoot, Xao\\DomDoc, Xao\\DomFactory, Xao\\AppDoc, Xao\\Http\\Response, and Xao\\Exceptions." order="5" active="false"/>
      <item slug="database-aggregation" title="Database Aggregation (DbToXml)" description="Convert PDO queries, PDOStatement results, and PHP iterables directly into structured DomDoc XML fragments under PHC." order="6" active="false"/>
      <item slug="markdown-aggregation" title="Markdown Aggregation" description="Convert CommonMark and GFM into CommonMark XML 1.0 natively in PHC via comrak and graft it into Xao DomDoc trees." order="7" active="false"/>
      <item slug="xslt-drivers" title="XSLT 3.0 Drivers" description="Pluggable XsltDriverInterface strategies: PhcNativeXsltDriver (default in-process), SaxonHttpDriver (HTTP/distributed), and ClientSideXslDriver." order="8" active="false"/>
    </section>
    <section name="Operations &amp; Runtime">
      <item slug="phc-runtime" title="PHC Runtime &amp; Compatibility" description="Running Xao on PHC in isolate and worker modes, sandbox defaults, worker-safe autoloading, and P00–P05 compatibility findings." order="9" active="true"/>
      <item slug="security" title="Security Model" description="XXE rejection, realpath containment, strict slug allowlists, CSRF guards, gated debug output, and PHC sandbox enforcement." order="10" active="false"/>
    </section>
    <section name="Examples &amp; Design">
      <item slug="reference-apps" title="Reference Applications" description="Comparing Xao's built-in SQLite PDO catalog reference app with XaoDocs, the flat-file Markdown multi-theme CMS." order="11" active="false"/>
      <item slug="adr-0001-phc-xee-xslt" title="ADR 0001 &amp; Roadmap" description="Architecture Decision Record for pure-Rust xee-xslt in PHC plus the Xao v1.0.0 milestone and phase roadmap (M0–M3, P00–P06)." order="12" active="false"/>
    </section>
  </navigation>
  <page slug="phc-runtime" title="PHC Runtime &amp; Compatibility" description="Running Xao on PHC in isolate and worker modes, sandbox defaults, worker-safe autoloading, and P00–P05 compatibility findings." section="Operations &amp; Runtime" audience="Operators and PHC contributors" status="stable" words="368" reading-minutes="2" source-file="content/phc-runtime.md">
    <tags>
      <tag>phc</tag>
      <tag>worker-mode</tag>
      <tag>sandbox</tag>
      <tag>compatibility</tag>
    </tags>
    <neighbors>
      <prev slug="xslt-drivers" title="XSLT 3.0 Drivers"/>
      <next slug="security" title="Security Model"/>
    </neighbors>
    <body>
      <document xmlns="http://commonmark.org/xml/1.0">
        <heading level="1">
          <text xml:space="preserve">PHC Runtime &amp; Compatibility</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">Xao is verified continuously against PHC (</text>
          <code xml:space="preserve">phc check</code>
          <text xml:space="preserve">, </text>
          <code xml:space="preserve">phc run</code>
          <text xml:space="preserve">, and </text>
          <code xml:space="preserve">phc serve</code>
          <text xml:space="preserve"> in both </text>
          <code xml:space="preserve">isolate</code>
          <text xml:space="preserve"> and </text>
          <code xml:space="preserve">worker</code>
          <text xml:space="preserve"> modes) alongside PHP 8.4 parity checks.</text>
        </paragraph>
        <heading level="2">
          <text xml:space="preserve">Summary of PHC Capabilities &amp; Workarounds</text>
        </heading>
        <table>
          <table_header>
            <table_cell>
              <text xml:space="preserve">Area</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Status</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Notes</text>
            </table_cell>
          </table_header>
          <table_row>
            <table_cell>
              <text xml:space="preserve">Worker-mode closure autoloader</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Workaround in place</text>
            </table_cell>
            <table_cell>
              <code xml:space="preserve">src/autoload.php</code>
              <text xml:space="preserve"> registers a named global function </text>
              <code xml:space="preserve">xao_autoload()</code>
              <text xml:space="preserve"> guarded by </text>
              <code xml:space="preserve">function_exists()</code>
              <text xml:space="preserve"> rather than an anonymous closure</text>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <code xml:space="preserve">DOMDocument</code>
              <text xml:space="preserve"> &amp; namespace-aware DOM</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Resolved in PHC </text>
              <code xml:space="preserve">P11</code>
              <text xml:space="preserve"> (</text>
              <code xml:space="preserve">xot</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Supports </text>
              <code xml:space="preserve">createElementNS</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">getElementsByTagNameNS</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">importNode</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">C14N</code>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <code xml:space="preserve">DOMXPath</code>
              <text xml:space="preserve"> queries &amp; predicates</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Resolved in PHC </text>
              <code xml:space="preserve">P11</code>
              <text xml:space="preserve"> (</text>
              <code xml:space="preserve">xee-xpath</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Supports </text>
              <code xml:space="preserve">query()</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">evaluate()</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">registerNamespace()</code>
              <text xml:space="preserve">, axes, predicates</text>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <code xml:space="preserve">xml:space="preserve"</code>
              <text xml:space="preserve"> text nodes</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Resolved in PHC (</text>
              <code xml:space="preserve">xml.rs</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Preserves leading/trailing spaces inside </text>
              <code xml:space="preserve">&lt;text xml:space="preserve"&gt;</code>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <text xml:space="preserve">Native XSLT 3.0 (</text>
              <code xml:space="preserve">xsl3</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Default build (</text>
              <code xml:space="preserve">P10</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <code xml:space="preserve">XSLTProcessor</code>
              <text xml:space="preserve"> in-process via pure-Rust </text>
              <code xml:space="preserve">xee-xslt</code>
              <text xml:space="preserve">/</text>
              <code xml:space="preserve">xot</code>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <text xml:space="preserve">CommonMark XML 1.0 (</text>
              <code xml:space="preserve">markdown-xml</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Default build (</text>
              <code xml:space="preserve">P12</code>
              <text xml:space="preserve">)</text>
            </table_cell>
            <table_cell>
              <code xml:space="preserve">phc_markdown_to_xml()</code>
              <text xml:space="preserve"> / </text>
              <code xml:space="preserve">phc_markdown_to_dom()</code>
              <text xml:space="preserve"> via </text>
              <code xml:space="preserve">comrak</code>
            </table_cell>
          </table_row>
          <table_row>
            <table_cell>
              <code xml:space="preserve">LIBXML_NONET</code>
              <text xml:space="preserve"> constant</text>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Guarded in </text>
              <code xml:space="preserve">DomDoc</code>
            </table_cell>
            <table_cell>
              <text xml:space="preserve">Checked with </text>
              <code xml:space="preserve">defined('LIBXML_NONET')</code>
              <text xml:space="preserve"> at runtime</text>
            </table_cell>
          </table_row>
        </table>
        <heading level="2">
          <text xml:space="preserve">Sandbox Defaults (</text>
          <code xml:space="preserve">phc.toml</code>
          <text xml:space="preserve">)</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">PHC executes request handlers inside a deny-by-default sandbox:</text>
        </paragraph>
        <list type="bullet" tight="true">
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">allow_network = false</code>
                <text xml:space="preserve"> by default:</text>
              </strong>
              <text xml:space="preserve"> Because </text>
              <code xml:space="preserve">PhcNativeXsltDriver</code>
              <text xml:space="preserve"> runs in-process, Xao and XaoDocs need zero network egress. Set </text>
              <code xml:space="preserve">allow_network = true</code>
              <text xml:space="preserve"> only when using </text>
              <code xml:space="preserve">SaxonHttpDriver</code>
              <text xml:space="preserve"> or fetching remote HTTP APIs.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">allowed_roots</code>
                <text xml:space="preserve">:</text>
              </strong>
              <text xml:space="preserve"> Explicitly list every directory accessed by the app (for example </text>
              <code xml:space="preserve">["public", "src", "stylesheets", "data"]</code>
              <text xml:space="preserve">, or </text>
              <code xml:space="preserve">["public", "src", "content", "themes", "../../Xao/src"]</code>
              <text xml:space="preserve"> in XaoDocs).</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">allow_file_databases</code>
                <text xml:space="preserve">:</text>
              </strong>
              <text xml:space="preserve"> Enable only when using file-backed SQLite databases via </text>
              <code xml:space="preserve">PDO</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <text xml:space="preserve">Relative paths in PHP:</text>
              </strong>
              <text xml:space="preserve"> Always anchor filesystem paths to </text>
              <code xml:space="preserve">dirname(__DIR__)</code>
              <text xml:space="preserve"> rather than </text>
              <code xml:space="preserve">getcwd()</code>
              <text xml:space="preserve">, which can differ between CLI (</text>
              <code xml:space="preserve">phc run</code>
              <text xml:space="preserve">), </text>
              <code xml:space="preserve">isolate</code>
              <text xml:space="preserve">, and </text>
              <code xml:space="preserve">worker</code>
              <text xml:space="preserve"> modes.</text>
            </paragraph>
          </item>
        </list>
        <heading level="2">
          <code xml:space="preserve">xee-xslt</code>
          <text xml:space="preserve"> Authoring Notes</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">When authoring stylesheets for </text>
          <code xml:space="preserve">PhcNativeXsltDriver</code>
          <text xml:space="preserve"> (</text>
          <code xml:space="preserve">xee-xslt</code>
          <text xml:space="preserve">):</text>
        </paragraph>
        <list type="bullet" tight="true">
          <item>
            <paragraph>
              <text xml:space="preserve">Prefer </text>
              <code xml:space="preserve">&lt;xsl:apply-templates select="..." mode="..."/&gt;</code>
              <text xml:space="preserve"> over </text>
              <code xml:space="preserve">&lt;xsl:call-template&gt;</code>
              <text xml:space="preserve"> (unsupported in current </text>
              <code xml:space="preserve">xee-xslt</code>
              <text xml:space="preserve">).</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Prefer XPath 3.1 sibling grouping (</text>
              <code xml:space="preserve">following-sibling::*[preceding-sibling::cm:heading[@level='2'][1] is $h]</code>
              <text xml:space="preserve">) over </text>
              <code xml:space="preserve">&lt;xsl:for-each-group&gt;</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Declare </text>
              <code xml:space="preserve">&lt;xsl:variable&gt;</code>
              <text xml:space="preserve"> bindings before any literal result elements in the same enclosing block, and format numbers with XPath expressions rather than </text>
              <code xml:space="preserve">&lt;xsl:number&gt;</code>
              <text xml:space="preserve"> or </text>
              <code xml:space="preserve">format-number()</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Use </text>
              <code xml:space="preserve">expand-text="yes"</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:include</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:import</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:output method="html"</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:param</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:element</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">xsl:attribute</code>
              <text xml:space="preserve">, and </text>
              <code xml:space="preserve">priority="2"</code>
              <text xml:space="preserve"> overrides freely.</text>
            </paragraph>
          </item>
        </list>
      </document>
    </body>
  </page>
</xao-docs>
