v0.27.6 · real DOOM and C-width buffers

PHP to
native assembly.

Pronounced el-ef-see — just spell out “LFC”.

elephc is a from-scratch compiler for a static subset of PHP: parse, type-check, lower to native assembly, assemble, and link. Standalone executables, shared and static libraries, iOS library targets, and three --web isolation modes today. No VM. No Zend Engine. No opcode fallback.

terminal
$ elephc hello.php
$ ./hello
Hello, World!
$ _

PHP compatibility

How much of PHP
compiles today

Counted symbol by symbol against PHP 8.5.10 (68 extensions, 2,169 functions) and generated from the compiler's own builtin registry, not maintained by hand.

Language

20/21

language features fully supported

Classes, enums, traits, closures, generators, fibers, match, references, namespaces. Partial: eval().

Default PHP build

71%

of PHP functions (644 / 901)

functions 71%
classes 63%
constants 33%

What a plain php-src ./configure compiles in: core, standard, date, pcre, spl, json, session, dom, and 20 more.

All 68 bundled extensions

45%

of PHP functions (983 / 2,169)

functions 45%
classes 52%
constants 37%

Everything in the reference PHP build, including opt-in extensions such as intl, gmp, sodium, and pgsql.

PHP extensions your framework requires

Complete Partial Missing

Laravel

13 required

4 complete · 6 partial · 3 missing

mbstring 100% pdo 100% session 100% xml 100% curl 98% hash 48% pcre 45% ctype 36% dom 15% openssl 6% fileinfo 0% filter 0% tokenizer 0%

Symfony

6 required

2 complete · 2 partial · 2 missing

iconv 100% session 100% pcre 45% ctype 36% simplexml 0% tokenizer 0%

WordPress

4 required

1 complete · 3 partial · 0 missing

json 100% mysqli 79% hash 48% pcre 45%

Percentages count each extension's functions and classes; an extension is complete only when its constants are all there too. Covering an extension is necessary, not sufficient: elephc compiles a static subset of PHP, so today frameworks keep running on PHP while their static modules compile to native libraries.

DOOM, played from the original WAD

Written in PHP, compiled to a native binary with elephc

17,000+ tests
1,074 built-in functions
24 data types
0 external runtime deps

Positioning

A compiler for PHP,
not a PHP wrapper

elephc stays close to the PHP ecosystem while drawing a clear technical line: supported code is compiled ahead of time to native assembly. Standalone executables, shared libraries, and static libraries are available today, with a PHP extension bridge on the roadmap.

Compiler model

From PHP source to native output

elephc is not a PHP packager and does not bundle Zend/PHP. It parses PHP, type-checks a supported static subset, lowers it to native assembly, then assembles and links it with a small runtime included in the output.

Runtime contract

If elephc compiles it, it runs as native code.

There is no interpreter, VM, Zend Engine, or opcode fallback waiting behind the compiled path. Unsupported dynamic behavior is a compiler boundary, not a silent fallback mode.

Framework direction

Keep your PHP framework, compile the hot paths.

The strategy is hybrid: WordPress, Laravel, Symfony, and other PHP applications can keep running on PHP while static modules move into native libraries today and PHP extensions in the future.

How is elephc different from PHP packagers or other PHP AOT systems?

elephc is a from-scratch compiler for a static subset of PHP. It is not a packager for the PHP runtime, and it does not ship Zend/PHP inside the result. The pipeline is parse, type-check, lower to native assembly, assemble, link, and include a small runtime in the binary. If elephc compiles it, it runs as native code.

Can elephc work with frameworks?

Not a drop-in replacement for an entire dynamic framework today, but a path to accelerate static modules inside existing PHP applications. Keep the framework on PHP, isolate static and performance-sensitive modules, and compile them into standalone executables or native libraries. A PHP extension bridge remains future work.

Get started

Install the
PHP compiler

elephc builds executables for macOS ARM64, Linux ARM64, and Linux x86_64, and cross-compiles libraries for iOS ARM64 devices and the iOS ARM64 Simulator. The elvm version manager installs releases side by side and selects a global or project-specific compiler.

Requirements

elvm installer: POSIX shell, curl, tar, and shasum or sha256sum
A native assembler and linker for your host/target
macOS: Xcode Command Line Tools
Linux: standard native toolchain (as, ld, libc dev files)
Source builds only: Rust toolchain (cargo)
Curated native packages: POSIX shell, Make, target cc, ar, ranlib
1. Install elvm
$ curl -fsSL https://get.elephc.dev | sh
# Accept the PATH prompt, then start a new shell
2. Install & select elephc
$ elvm install latest
$ elvm use latest --global
# Pin this project instead
$ elvm install 0.27.6
$ elvm use 0.27.6
3. Compile & run
$ elephc hello.php
$ ./hello
Hello, World!
# Or start an interactive session
$ elephc repl
Alternative installs
# Homebrew (macOS)
$ brew install illegalstudio/tap/elephc
# mise
$ mise use -g github:illegalstudio/elephc@latest
# Or from source
$ git clone https://github.com/illegalstudio/elephc.git
$ cd elephc && cargo build --release

Manual release downloads and complete setup details are in the installation guide.

Project structure

src/
main.rs — CLI entry point
lexer/ — source → tokens
parser/ — tokens → AST
types/ — static type checking
codegen/ — AST → native asm
builtins/ — one file per function
strings/ arrays/ math/ types/ io/ spl/ system/
runtime/ — target runtime routines
strings/ arrays/ exceptions/ io/ system/
errors/ — file:line:col formatting

Roadmap

0.1.0 Basic CLI compiler
0.27.4 Native testing with isolation and JUnit reports; explicit C integer widths (breaking) and f32 FFI; floating-point pointer helpers; strip_tags(), BcMath\Number, WeakMap, Core symbols, and an HTML-only DOM subset; JSON enum support; tail-recursion, eval, memory, and array optimizations; runtime compatibility fixes, macOS notarization, and TLS security updates
0.27.5 Security fixes for --web sessions and request state; natural C layout for extern class fields (breaking for bool); integer loop counters and buffer loop optimizations; pointer formatting and nested packed record fixes
0.27.6 The real DOOM showcase; C-width packed fields and buffer elements; arrays of pointers and buffers; static buffer and pointer properties; buffer_ptr() and nullable extern strings; relative namespace\ names; PHP string ordering; final-class dispatch and small-method inlining; filenames in diagnostics; memory-safety and runtime compatibility fixes current
next PHP extension bridge for framework integration
next Multi-file library builds and pkg-config metadata
1.0.0 Production-ready