v0.25.2 — prefork web server & EIR inliner

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 binaries and a prefork HTTP server (--web) today; native libraries and PHP extension bridge on the roadmap. No interpreter. No VM. No Zend Engine. No opcode fallback.

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

Doom-style 3D engine

Written in PHP, compiled to a native binary with elephc

3000+ tests
400+ built-in functions
21 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. The roadmap extends that model from standalone binaries into native libraries and a PHP extension bridge.

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 long-term strategy is hybrid: WordPress, Laravel, Symfony, and other PHP applications can keep running on PHP while static modules move into native libraries or PHP extensions.

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. The intended path is pragmatic: keep the framework on PHP, isolate static and performance-sensitive modules, and compile those into standalone binaries today, then native libraries or PHP extensions as that bridge lands.

Get started

Install the
PHP compiler

elephc is written in Rust and targets macOS ARM64, Linux ARM64, and Linux x86_64. Three commands to install the compiler and compile your first PHP file to a native binary. Native library and PHP extension outputs are future integration targets, not required for today's CLI flow.

Requirements

Rust toolchain (cargo)
A native assembler and linker for your host/target
macOS: Xcode Command Line Tools (or Homebrew)
Linux: standard native toolchain (as, ld, libc dev files)
1. Install
# Homebrew (recommended)
$ brew install illegalstudio/tap/elephc
# Or from source
$ git clone https://github.com/illegalstudio/elephc.git
$ cd elephc && cargo build --release
2. Compile & run
$ elephc hello.php
$ ./hello
Hello, World!
3. Run the tests
$ cargo test
# 3000+ tests, all passing

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/ — line:col formatting

Roadmap

0.1.0 Basic CLI compiler
0.25.0 EIR dead instruction elimination, branch simplification, and PHP date/time & calendar support
0.25.1 Image support, EIR dead store elimination, constant folding, CSE, LICM, and `--web` prefork HTTP server
0.25.2 Full `--web` server, EIR small-function inliner, module-level fixed-point pipeline, and CSE fixes current
next PHP extension bridge for framework integration
next Shared/static library output for compiled modules
1.0.0 Production-ready