What Is elephc? A PHP Compiler With No VM and No Zend Engine
Direct answer: elephc is an open-source compiler, written in Rust, that turns a subset of PHP straight into native assembly. It doesn't use the Zend Engine or a VM, and the output is a standalone binary or library. As of November 2026 (v0.27.8) it's fast-moving and experimental: worth trying for CLI tools, compute-heavy modules and PHP extensions, but not for compiling a whole Laravel app.
"DOOM, written in PHP, compiled to a native binary" sounds like a joke, and the first question it invites is: why? The answer is more interesting than the demo. elephc is the most aggressive attempt yet to make PHP a compiled language without leaving PHP syntax, and it's changing faster than any PHP project I follow. Here's what it does, what it can't do, and where I'd actually use it.
What is elephc?#
elephc (pronounced "el-ef-see") is a PHP-to-native compiler from Illegal Studio, created by Vincenzo Petrucci with Guillaume Loulier as a core contributor. It's MIT licensed. Petrucci writes that his first serious programming book was PHP 4 and MySQL, and elephc is his answer to a gap he always felt: compiling PHP to native code while staying in the PHP ecosystem.
The pipeline is short:
- Parse your PHP.
- Type-check it, inferring types where you didn't write them.
- Lower it to target-specific assembly (you can read the generated
.sfile). - Assemble and link with the system's
asandld, plus a small runtime.
No interpreter loop, no opcodes, no JIT. That's the big difference from PHP's own JIT and from TypePHP, which goes through C++ and keeps parts of the Zend runtime. I cover that comparison in elephc vs TypePHP.
$ elephc hello.php
$ ./hello
Hello, World!
What elephc supports in late 2026#
More than you'd expect from a 0.x project. The site lists 20 of 21 language features as fully supported: classes, enums, traits, closures, generators, PHP 8.1-style Fibers, match, references and namespaces. eval() is partial.
For the standard library, elephc measures itself against PHP 8.5.10 and publishes the numbers, which I appreciate:
| Measure (vs PHP 8.5.10) | Supported |
|---|---|
| Functions in a default PHP build | 666 of 901 (74%) |
| Functions across all 68 bundled extensions | 1,078 of 2,169 (50%) |
| Extensions Laravel requires | 6 of 13 complete |
| Extensions Symfony requires | 4 of 6 complete |
| Extensions WordPress requires | 2 of 4 complete |
The README's generated builtin reference lists 1,196 PHP-visible entries. Those two counts measure different things, so don't be surprised if you see different "how many functions" numbers quoted around the web.
Targets. Executables build for macOS ARM64, Linux ARM64 and Linux x86_64. A macOS host can also cross-compile libraries for iOS ARM64 devices and the iOS simulator; those targets don't run Fibers. Windows and Intel Macs aren't listed.
Output types. This is where elephc gets practical:
- Standalone executables for CLI tools and services.
--emit phpext: a.somodule that a normal PHP 8.5 install loads like any extension. You write the extension in PHP instead of C.--emit cdyliband--emit staticlib: shared and static libraries other languages can call.externdeclarations for C FFI, so compiled PHP can call C libraries such as SDL (which is how the DOOM demo draws to the screen).
The DOOM demo, and why it matters#
The showcase runs the shareware episode from the original DOOM1.WAD "entirely in PHP compiled to a native binary," at DOOM's native 35 tics per second. It's a stunt, but a useful one. A game loop is a brutal test of a compiler: tight numeric code, arrays everywhere, no tolerance for a slow frame. Getting it to run proves the type inference and code generation work on something bigger than a benchmark script.
It doesn't prove your Laravel app will compile. Those are very different kinds of code.
What elephc can't do#
elephc is honest about this, and you should be too before you pitch it to your team.
- It's not a drop-in replacement for PHP. The project says so directly. Unsupported dynamic behaviour becomes a compile-time error, not a runtime fallback.
- Frameworks stay on PHP. Laravel and Symfony lean on reflection, magic methods, dynamic container resolution and runtime-generated code. elephc's own advice is to keep the framework on regular PHP and move static, performance-sensitive modules into native libraries or extensions.
eval()is a special case. The README says eligible literaleval()fragments are compiled ahead of time, and dynamic ones can fall back to an optional, statically linked interpreter called Magician. The website describes "no interpreter, VM, Zend Engine, or opcode fallback". I read that as the default build, with Magician as an opt-in exception, but check the current docs if it matters to you.- 0.x means 0.x. The roadmap marks 1.0.0 as the production-ready milestone. Next on the list: multi-file library builds, pkg-config metadata and a WebAssembly target.
Where I'd use elephc today#
The pattern that makes sense is hybrid: your app stays on normal PHP, and one hot, well-typed module gets compiled.
- A PHP extension you'd otherwise write in C. A pricing engine, a parser, a geometry routine.
--emit phpextlets PHP developers own it. - Single-binary CLI tools. Ship an internal tool to servers or teammates without "install PHP 8.5 and these extensions first".
- Learning. Reading the generated assembly for your own PHP is the best compiler course I can think of for a PHP developer.
Where I wouldn't: anything I can't afford to rewrite if the project changes direction. And before compiling anything, profile. Most slow PHP web apps are slow because of queries and boot time, which Octane with Swoole or a better query plan fixes more cheaply.
Getting started#
elephc has its own version manager, elvm, which I'd use so you can pin a version per project (worth doing at this release pace):
curl -fsSL https://get.elephc.dev | sh
elvm install 0.27.8
elvm use 0.27.8
# or
brew install illegalstudio/tap/elephc
You need a native assembler and linker: Xcode Command Line Tools on macOS, a standard build toolchain on Linux. Rust is only needed if you build elephc from source. Try elephc repl to poke at it interactively.
As always with a piped install script, read it first.
Frequently asked questions#
Is elephc production ready?#
Not yet. As of November 2026 it is at v0.27.8 and describes itself as experimental; the roadmap marks 1.0.0 as the production-ready release. It is reasonable for isolated tools and modules you can rewrite.
Can elephc compile Laravel?#
No. elephc compiles a subset of PHP and treats unsupported dynamic behaviour as a compile error. Its advice is to keep Laravel or Symfony on regular PHP and compile static, performance-sensitive modules as extensions or libraries.
How is elephc different from the PHP JIT?#
The PHP JIT runs inside the Zend Engine and compiles hot code at runtime. elephc compiles ahead of time to a standalone native binary or library with no Zend Engine at all.
What platforms does elephc support?#
Executables for macOS ARM64, Linux ARM64 and Linux x86_64, plus iOS ARM64 device and simulator libraries cross-compiled from macOS.
Can I write a PHP extension with elephc?#
Yes. elephc --emit phpext builds a .so module that a standard PHP 8.5 install can load, so you can write an extension in PHP instead of C.
Key takeaways#
- elephc compiles a subset of PHP directly to native assembly with a small runtime: no Zend Engine, no VM, no JIT. It's written in Rust and MIT licensed.
- v0.27.8 (November 13, 2026) covers 74% of a default PHP 8.5 build's functions and 20 of 21 language features, with
eval()partial. - It builds executables for macOS ARM64 and Linux, libraries for iOS, and
.soextensions that stock PHP 8.5 can load. - Use it hybrid: keep Laravel or Symfony on PHP and compile isolated, typed hot paths or CLI tools.
- It's pre-1.0 and changes almost daily. Pin versions and don't bet anything you can't rewrite.
Sources#
- illegalstudio/elephc on GitHub (README, builtin reference)
- elephc releases (v0.27.8, November 13, 2026)
- elephc.dev (compatibility figures, roadmap, install)
Have a PHP hot path you're tempted to compile? Tell me about it.