v0.27.7 · PHP extensions and GMP

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

74%

of PHP functions (663 / 901)

functions 74%
classes 69%
constants 50%

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

All 68 bundled extensions

49%

of PHP functions (1,053 / 2,169)

functions 49%
classes 56%
constants 42%

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

6 complete · 6 partial · 1 missing

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

Symfony

6 required

3 complete · 2 partial · 1 missing

iconv 100% session 100% tokenizer 100% pcre 45% ctype 36% simplexml 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

18,000+ tests
1,146 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, static libraries, and PHP 8.5 extensions are available today.

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 or real 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. Keep the framework on PHP, isolate static and performance-sensitive modules, and compile them into standalone executables, native libraries, or PHP 8.5 extensions loaded by the existing PHP runtime.

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.7
$ elvm use 0.27.7
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.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
0.27.7 PHP 8.5 extensions with --emit phpext; statically linked PECL, PIE and C extensions; persistent web applications; GMP, fileinfo, Random engines and tokenizer; memory_get_usage(), array_first() and array_last(); string-offset writes and nested pointer types; 128 MB default heap and faster allocation; numeric, buffer and eval optimizations; memory-safety and runtime compatibility fixes current
next Multi-file library builds and pkg-config metadata
next WebAssembly target
1.0.0 Production-ready