XaoDocs Accessible Linear Edition

Document Summary

Getting Started

Set up PHC, autoload Xao with zero Composer packages, transform your first DomDoc with XSLT 3.0, and run phc serve.

Section
Start Here
Target audience
Developers new to Xao and PHC
Estimated reading time
1 minute(s) (183 words)
Major sections
4

Xao requires zero Composer runtime dependencies. Everything runs directly on the PHC Rust application server (phc default build with built-in xsl3 and markdown-xml extensions) or standard PHP 8.4+.

Prerequisites

Verify that your phc binary includes the default-on xsl and markdown-xml features:

Code example (bash)
phc -m
phc run -r 'var_dump(extension_loaded("xsl"), function_exists("phc_markdown_to_xml"));'

Both checks should return bool(true).

Autoloading Xao

Include src/autoload.php once at the top of your entrypoint (or register it in phc.toml under [worker] bootstrap):

Code example (php)
<?php

declare(strict_types=1);

require_once __DIR__ . '/src/autoload.php';

use Xao\DomDoc;
use Xao\Xslt\Transformer;

$doc = new DomDoc('catalog');
$doc->ndAppendToRoot('item', 'Xao', ['slug' => 'xao']);

$transformer = Transformer::createDefault(__DIR__ . '/stylesheets');
echo $transformer->transform($doc, 'catalog.xsl');

Transformer::createDefault() inspects the runtime environment and automatically selects:

  1. Explicit override via $forcedDriver or XAO_XSLT_DRIVER ('native', 'saxon', or 'client').

  2. PhcNativeXsltDriver when extension_loaded('xsl') is true (default in PHC).

  3. SaxonHttpDriver when a sidecar URL is supplied.

  4. ClientSideXslDriver as a zero-infra fallback.

Running Under phc serve

Place a phc.toml file at your project root:

Code example (toml)
[server]
listen = "127.0.0.1:8080"
document_root = "public"
front_controller = "index.php"
mode = "isolate"
workers = 2
queue = 16

[sandbox]
allowed_roots = ["public", "src", "stylesheets", "data"]
allow_network = false
allow_file_databases = true

[worker]
bootstrap = "src/autoload.php"

[ini]
display_errors = "0"

Start the server in either isolate mode or persistent worker mode:

Code example (bash)
phc serve phc.toml

Notice allow_network = false works out of the box because PhcNativeXsltDriver runs XSLT 3.0 completely in-process with no external sidecar.

Running Xao's Own Test & Parity Suites

From the Xao repository root:

Code example (bash)
./scripts/test.sh        # phc check + 12 PHP 8.4 vs PHC parity unit tests
./scripts/smoke-serve.sh # live phc serve HTTP smoke checks (isolate + worker)
bash scripts/ci.sh       # php -l + unit tests + Markdown relative-link check