PHP Toolkit

Experimental performance preview

10x the php-toolkit speed

Try the experimental wp_native_apis extension in WordPress Playground first. It loads before PHP starts, confirms the WASM extension was registered, and shows quick browser-side timing numbers for hot WP_HTML_Tag_Processor, XMLProcessor, and URLInTextProcessor paths.

Quick start

Try in Playground web

Open a ready-made Playground that loads the latest PHP.wasm manifest with php-extension, installs the smoke-test Blueprint, and lands on /native-api-smoke.php.

Test in Playground →

Try in Playground CLI

Use the same manifest locally. The extension flag must be passed before PHP starts.

npx @wp-playground/cli@latest server \
  --php=8.5 \
  --php-extension=https://wordpress.github.io/php-toolkit/wp_native_apis-wasm-extension/latest/manifest.json \
  --blueprint=https://raw.githubusercontent.com/WordPress/php-toolkit/trunk/extensions/native-apis/playground/blueprint.json
What you should see: the Playground page says wp_native_apis WASM extension loaded, then shows whether native classes are available and a few quick timing cards.

What this accelerates

WP_HTML_Tag_Processor

Fast scans and aggregate checks for common tag-processor and fragment-processor workloads.

Reference →

XMLProcessor

Streaming token, tag, namespace, attribute, and inventory summaries without building a DOM tree.

Reference →

URLInTextProcessor

A native candidate scanner for plain-text URL detection, with public handling still validating through the existing parser path.

Reference →

Status and fallback behavior

Experimental: the packaging, release cadence, and accelerated surface are still evolving. The PHP Toolkit APIs remain safe to use without the extension.

When wp_native_apis is loaded before the toolkit, wrappers may delegate covered operations to native classes. If the extension is missing, incompatible, or disabled with WP_NATIVE_APIS_DISABLE_DEFAULTS, the same public APIs continue through pure-PHP implementations.

WASM releases for Playground

The release index is for pinned manifests, checksums, and exact Playground links. Use latest for a quick trial; use a commit-specific manifest when you need a reproducible demo.

Browse WASM releases for Playground →

Benchmarks

The 10x claim comes from CI benchmark snapshots for the host Rust-backed extension. Playground is the easiest way to see that the extension loads and to get quick browser-side timing numbers; host PHP benchmarks are the better signal for Rust-backed throughput.

php -d extension=extensions/native-apis/target/release/libwp_native_apis.so \
	bin/benchmark-native-apis.php --iterations=50 --mode=both --disable-native-defaults --require-native

Benchmark numbers are machine- and workflow-run-specific. Treat them as directional evidence for which workflows benefit from native batching, not as universal throughput guarantees.

Compile for native PHP

After trying Playground, build the Rust-backed extension for your local host PHP ABI when you want the real native implementation and benchmark numbers. A build made for one PHP ABI cannot be reused for another.

Build the native PHP extension →