Sulat.com / Writing on AIFriday, November 27, 2026
Developer Tools/27 November 2026

Elephc compiles PHP to native code. Its SymfonyCon talk makes big claims; here is what holds up

A SymfonyCon talk says Elephc, a Rust-built compiler for a static subset of PHP, is 15 to 20 times faster than PHP with JIT. The speaker is a core contributor, so I checked the claims against the repository, the docs and my own timing.

3D render of a glowing pink and orange lightning-bolt mark floating above a chip on a silver plinth, beside a stack of glass code cards
Illustration: Sulat

At a glance

  • Elephc is a from-scratch ahead-of-time compiler for a static subset of PHP, written in Rust, and its SymfonyCon Warsaw talk was posted on 26 November by Guillaume Loulier, a core contributor.
  • The headline 15 to 20x speedup is a whole-process figure on three micro-benchmarks, and in my run of the slide's loop on PHP, startup made up nearly all of the time.
  • The most practical route is the extension output: compile one typed function into a PHP 8.5 extension and keep the rest of the app on PHP, with strings and arrays copied at the boundary.
  • The full Symfony build is a 1,064-commit pull request in review, not a tagged release, and pcre, a required Symfony extension, is at 73%.
  • The main branch's changelog makes elephc build the required command in 0.27.10, while the slides, the site and the latest tagged release still show the old form.

Elephc is a from-scratch, ahead-of-time compiler that turns a static subset of PHP into native machine code. It is written in Rust, MIT licensed, and its pitch was the subject of a SymfonyCon Warsaw talk this week. Guillaume Loulier posted the slides, “Pedal to the Metal: Compiling PHP to native code”, on Speaker Deck on 26 November. He is not a neutral third party. The project’s README lists him as a core contributor beside its creator, Vincenzo Petrucci of Illegal Studio, and he authored all five pull requests the slides show as in flight.

So I checked the talk against the repository, the docs and the project’s own changelog, and I timed the PHP half of the benchmark myself. The compiler is real and moving fast. The headline “15 to 20x faster than PHP with JIT” is a whole-process figure on three micro-benchmarks, and in my run most of PHP’s time was startup. The Symfony build the talk leads towards is not in a tagged release.

Illustration: a scalpel points at one glowing blue file in a tall stack of grey PHP files, with the line compile only what earns it
The talk’s positioning: Elephc sits next to PHP and compiles the parts that earn it.

What the talk argues

Loulier’s starting point is that writing PHP means writing for an interpreter. A request goes through OPcache and the Zend VM, with the JIT only for hot paths. He calls the limit the interpreter wall and splits it into three parts:

  1. Speed. About 80% of an app is I/O-bound and 20% is CPU-bound: parsers, image processing, tight arithmetic.
  2. Reach. Off the server, PHP has to bring its engine with it. NativePHP embeds the interpreter, and otherwise PHP is API-only.
  3. Language. The type system, and generics in particular.

The two usual reflexes, he says, both leave PHP: write a C extension, or rewrite in Go or Rust. Elephc is offered as a third route. Slide 10 gives the lesson from earlier projects: HipHop, KPHP and PeachPie tried to replace PHP, and Elephc “sits next to it and compiles only what earns it”. The slides’ phrase is “Not a replacement. A scalpel.”

Two stacked boxes: routing, templates, fast-changing and unprofiled code stay on PHP; measured hot paths, typed stable code and code that must run without PHP get compiled
The talk’s rule of thumb for splitting work between PHP and compiled code.

How Elephc works

The repository describes a conventional compiler pipeline: lexer, parser, goto lowering, resolver, type checker, optimiser, reachability pass, an SSA intermediate form called EIR, register allocation, assembly, then the host assembler and linker. The type checker is where generics are specialised. The project’s contract is “If it compiles, it’s native”: there is no Zend engine, VM or opcode fallback. The one exception is an experimental eval() that can embed an optional interpreter bridge the project calls Magician.

Diagram: Elephc passes PHP through a lexer and parser, a type checker that specialises generics, an optimiser and SSA form, then register allocation, assembly and linking, ending in an executable, shared library, static library or PHP 8.5 extension
The pipeline as documented in the Elephc repository, ending in one of four output kinds.
FactWhat the project documents
TargetsmacOS aarch64, Linux aarch64, Linux x86-64, and iOS arm64 and simulator for libraries only. No Windows, no WebAssembly.
OutputsAn executable, a C-ABI shared library with a generated header, a static library, or a PHP 8.5 extension.
MemoryA free-list and bump heap (128 MB by default, set with --heap-size), reference counting, copy-on-write arrays and a targeted cycle collector.
Known gapCycles through suspended Fiber or Generator frames are never collected, and raw or off-heap ownership cycles are outside the collector.
SizeCreated on 21 March 2026, about 11,600 commits at the time of writing, 1,208 built-in functions and more than 20,000 tests, per elephc.dev.
From the repository’s README and docs and the project site, checked on 27 November.

The benchmark, and what I measured

Slides 12 and 13 carry the headline: “15–20x faster than PHP with JIT, start to finish. Neck and neck with C.” The numbers come from Elephc’s own CI on 17 November, on macOS arm64 with PHP 8.5.12, median of three runs, whole-process wall time.

CasePHP with JITElephcC at -O2Speedup
sum_loop65.0 ms3.5 ms3.2 ms19x
array_sum61.0 ms3.9 ms3.2 ms15x
string_concat80.7 ms4.0 ms4.2 ms20x
Slides 12 and 13 of the talk. Elephc CI, macOS arm64, PHP 8.5.12, median of three.

The slide’s own footer says these are micro-benchmarks, that PHP “pays startup, compile and JIT warm-up each run”, and that “your gain depends on your hot path, so measure it.” The repository’s benchmark README adds that Elephc’s times exclude its own compilation and linking. Those are fair disclosures, and they change what the figure means.

I ran the slide’s exact loop on PHP 8.3.6, the command-line build, on Linux x86-64 in my own environment. It prints 20000100000, matching the slide.

Code
<?php
$sum = 0;
$i = 1;
while ($i <= 200000) {
    $sum += $i;
    $i += 1;
}
echo $sum . "\n";

26.5 ms

the loop, JIT on, median of 21 runs

24.4 ms

an empty script, same flags

10.3 ms

the loop, no OPcache or JIT

8.7 ms

an empty script, no OPcache or JIT

On my machine the loop itself costs about 2 ms either way, and the empty script accounts for nearly all of the rest. That is not Elephc’s hardware and not PHP 8.5.12, so my absolute numbers don’t test theirs. What it shows is the shape: with a loop this short, the whole-process gap between PHP and a native binary is mostly interpreter startup. The 15 to 20x is true of the process, and it says little about how fast either side runs a long computation.

Illustration: a long bar labelled process startup with a tiny blue sliver at the end labelled the loop, titled startup is most of the time
In my own timing of the slide’s loop, startup made up most of the whole-process time.

I did not run Elephc. Building it here was blocked, so everything about its behaviour in this piece comes from the slides, the repository and its docs, and none of it from my own run.

The hybrid route: compile one function, keep the rest

The most practical idea in the talk is the extension output. Slide 14 shows a store-locator function marked with an #[Export] attribute, nearest(array $stores, float $lat, float $lng): int. The command elephc --emit phpext geo.php builds it into a real PHP extension, and one line, extension=geo.so, in php.ini loads it. The rest of the application stays ordinary PHP. The docs set the limits:

  • It needs a PHP 8.5 development SDK, on Linux x86-64, Linux aarch64 or macOS aarch64. Thread-safe or not is allowed, provided the headers and the interpreter agree.
  • Values that cross the boundary are int, float, bool, binary string, array, null, and objects of exported classes. Exported parameters need explicit types.
  • Strings and arrays are copied in both directions at the boundary. A function that takes a large array and returns a small result pays for the copy in.

The same machinery runs the other way. With elephc extension add and a Rust crate called elephc-zend, which rewrites the Zend extension API in Rust, a compiled program can host existing PECL or PIE extensions. The slide says 17 PECL extensions were tested against PHP 8.5: 14 behaved identically and 3 lost only the file and line in warnings. Zend extensions such as Xdebug are refused, and there are no streams or sessions. For web work, --web builds a standalone prefork HTTP server binary, and elephc monitor --apm adds profiling and APM.

Generics, and PHP’s own attempt

Elephc accepts native class Box<T> syntax, or @template docblocks, and specialises each use per type argument at build time. Slide 17 benchmarks 3 million iterations: a generic Box<int> and a hand-written int class both took 0.11 s, and an untyped mixed version took 0.21 s.

That sits against PHP’s own history, which slide 8 lays out as a timeline. Runtime generics stalled on type inference in 2024, and a compile-time-only version was floated in 2025 without a proposal. In 2026 the Bound-Erased Generic Types RFC by Seifeddine Gmati was declined, with 7 votes for and 19 against in a vote that ran from 14 to 28 June. A pre-RFC thread on reified generics opened on 6 August. The slide quotes the PHP Foundation as saying that checking generics on live objects is “an order of magnitude harder”. Elephc resolves each generic use before the program runs, which works because it compiles the whole program it sees.

DOOM, and “plain PHP”

Slide 19 is the showpiece: DOOM written in PHP and compiled by Elephc, in its own repository. The README says it runs at 60 FPS, about 2 ms per frame on a desktop x86-64 CPU (the slide shows 2.51 ms), needs only SDL2 at runtime, and was written from public WAD and format descriptions, not DOOM’s source.

The same README carries the fine print. Hot loops have to use specific shapes to stay machine integers. $i += 1 and $i = $i + 1 keep the counter boxed, as do <= comparisons and $n + 1 bounds. $i++ against an int-typed bound does not. An object argument costs about 20 ns per call, ten times an int-only call. That is useful knowledge for anyone writing for the compiler, and it sits awkwardly beside a slide that calls the code plain PHP, untouched. The loop in the benchmark above uses $i += 1.

Illustration: a cartoon elephant steps on a counter showing a ticked i plus plus and a crossed-out i plus equals 1, titled plain PHP with conditions
The DOOM port’s notes say some loop shapes keep counters as machine integers and others do not.

Where it stands

Slide 18 gives the status at v0.27.9: 20 of 21 language features shipped (eval() is partial), 24 data types, 678 of the 901 functions in the default PHP build (75%), extension export, CLI, web, iOS and C libraries, and the profiler and APM. Its in-flight list is Symfony compiled whole (pull request 2205, with 8 of 8 web responses and 57 of 57 console commands matching PHP), a native debugger (2267), async and parallel (958), WebAssembly with WAMR (420) and Windows x86-64 (446). Planned are multi-file libraries in v0.28 and 1.0 as a stable contract, “not a date”. The slide’s verdict is plain: today it is an extension or a standalone tool, and the whole-framework build is still in review.

Three stacked boxes of Elephc v0.27.9 status: shipped features, work in flight such as Symfony, debugger, async, WebAssembly and Windows, and planned multi-file libraries and 1.0
Status as shown on the talk’s slide for v0.27.9.

The pull requests tell more than the slide. All five in-flight items were opened by Loulier. Pull request 2205, “Closed-world Symfony build (web + console) at php parity”, has 1,064 commits and was created on 1 November, with review requested from Petrucci. The 8 of 8 and 57 of 57 figures are the author’s own verification. The description reports the full suite on macOS aarch64 at 4,157 passed and 83 failed in the library tests, the same as the baseline, and says Laravel work is included but “not verified or claimed”. It also lists known divergences from PHP: a non-numeric string passed to an int parameter becomes 0 where PHP throws a TypeError.

Compatibility on elephc.dev is more modest than “Symfony compiled”. Of the six extensions Symfony requires, five are complete and one, pcre, is at 73%. WordPress needs four, two complete and two partial: pcre at 73% and hash at 48%. The site’s own wording is that frameworks keep running on PHP while their static modules compile to native libraries. The roadmap keeps the 0.x line on PHP parity and backend foundations, puts the include graph and library completion in 0.28, WebAssembly in 0.30, and says 1.0 is not an active planning gate.

The peers

ProjectApproachWhat its own docs say
KPHP (VK)Compiles a limited PHP subset to C++, then a native binary served by an embedded HTTP serverOpen-sourced in late 2020. Claims 3 to 10x over PHP. Says it rarely compiles existing code without errors. No generators or anonymous classes.
PeachPieRoslyn-based PHP compiler for .NETDescribes itself as a work in progress, maintained in spare time.
FrankenPHPEmbeds the real PHP interpreter and Caddy, with static builds and an embed mode that packs an app into one binary1.14.0 on 21 November made PHP 8.6 the default. Elephc’s extension output targets PHP 8.5, and extensions are built per PHP version.
TypePHP (Swoole)Self-hosting ahead-of-time compiler from PHP to C++17, with binary, extension and library modesPHP News reported about 8x on its main benchmark (5.034 s to 0.603 s) and a documented list of incompatible features.
PHP’s JITTracing JIT inside the interpreterThe baseline in Elephc’s table.
ElephcStatic subset to native code, with extension and library outputContract: no interpreter fallback. Benchmarks are its own.
Peers compared on approach and on what each project says about itself. None of the speedup claims has been independently tested here.

The difference that matters is where each one stops. FrankenPHP and static builds keep the interpreter and make it easier to ship, so PHP’s semantics survive intact. KPHP, TypePHP and Elephc give up part of the language for speed and a standalone binary, and the cost shows up as a list of things that won’t compile. Elephc’s distinguishing bet is the extension output, which lets the compiled part live inside an unchanged PHP deployment. It sits closer to the Rust-for-hot-paths pattern than to a rewrite, which is the route Appwrite described when it moved its server from PHP to Rust. The same pull towards native tooling is visible in Pun, a one-binary PHP toolchain, and in the four Rust rewrites of Composer that Sebastian Bergmann questioned.

Trying it, and the CLI change

The install route on elephc.dev is a script and a version manager:

Code
curl -fsSL https://get.elephc.dev | sh
elvm install latest && elvm use latest --global

One trap for anyone following the slides. The changelog on the main branch has a 0.27.10 entry dated 26 November in which elephc build <source-file> becomes the required form, alongside a new elephc check, and old invocations print a migration hint. The slides and elephc.dev still show elephc hello.php. The releases page lists v0.27.9, from 20 November, as the latest tag, and the code in Cargo.toml says 0.27.9, so 0.27.10 is changelog text that isn’t yet a tagged release. Nightly builds are published daily.

A five-point check before putting it near production

1. Profile first. The talk’s own advice is to compile a measured hot path. Time your function, not a loop of $i += 1.

2. Count the boundary copies. Strings and arrays are copied in both directions, so pass small inputs and return small results.

3. Match the PHP version. The extension output targets PHP 8.5, and you need its development SDK.

4. Check the functions you call. 678 of 901 default-build functions is 75%, and pcre sits at 73%.

5. Pin the version. The CLI changed between the talk and the changelog, and the project is on 0.x.

The talk’s last slide asks for the right kind of help: point it at your hot path and report what doesn’t compile, finish Symfony’s last partial, and add docs, examples and benchmarks. That is a fair summary of the project too. It is early, it is open about where it stops, and the claims worth testing are the narrow ones.


Sources: Guillaume Loulier, slides / Elephc repository / Elephc changelog / Elephc roadmap / Pull request 2205 / DOOM in Elephc / PHP RFC, bound-erased generics / KPHP / PeachPie / FrankenPHP / PHP News, TypePHP


Discover more from Sulat AI & Tech News

Subscribe to get the latest posts sent to your email.