[ XAO ] OPS CONSOLE
SLUG: getting-startedSECTION: Start HereSTATUS: stableWORDS: 183READ: 1mENGINE: phc/xsl3

Getting Started

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

View source XML

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+.

01Prerequisites

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

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

Both checks should return bool(true).

02Autoloading Xao

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

<?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.

03Running Under phc serve

Place a phc.toml file at your project root:

[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:

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.

04Running Xao's Own Test & Parity Suites

From the Xao repository root:

./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