elephc — PHP to Native Assembly Compiler
v0.26.6 · native extension and tooling expansion

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!
$ _

Doom-style 3D engine

Written in PHP, compiled to a native binary with elephc

10,000+ tests
549 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. 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.26.6
$ elvm use 0.26.6
3. Compile & run
$ elephc hello.php
$ ./hello
Hello, World!
Alternative installs
# Homebrew (macOS)
$ brew install illegalstudio/tap/elephc
# 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/ — line:col formatting

Roadmap

0.1.0 Basic CLI compiler
0.26.4 BCMath decimal arithmetic, OpenSSL-compatible encryption, parse_url(), and an eleven-driver PDO matrix
0.26.5 mysqli, web isolation modes, whole-program declaration pruning, and smaller release binaries
0.26.6 curl, native profiling, iOS library targets, and recoverable library ABI v3 current
next PHP extension bridge for framework integration
next Multi-file library builds and pkg-config metadata
1.0.0 Production-ready
elephc

An open-source PHP compiler that lowers a static subset of PHP to native assembly for macOS ARM64, Linux ARM64, Linux x86_64, and iOS ARM64 library targets. Written in Rust. MIT licensed.

Learn

How it works Language reference Resources ARM64 assembly primer Memory model

The story

My first "serious programming" book was PHP 4 and MySQL. That book turned passion into profession. elephc fills a gap I always missed — compiling PHP modules to native code without leaving the PHP ecosystem behind.

// coming next

Want to be among the first to explore cloud-native compiled PHP? Create artifacts, ship native binaries, and host projects built with elephc - no traditional runtime required.

Sign up for elephc.cloud

Made with ❤️ in Canzano by Vincenzo Petrucci [at] Illegal Studio

MIT License © 2026 Vincenzo Petrucci