Back to browse
GitHub Repository

A PHP-to-native compiler. Takes a subset of PHP and compiles it directly to native assembly, producing standalone binaries for the currently supported targets: macOS ARM64, Linux ARM64, and Linux x86_64. No interpreter, no VM, no runtime dependencies.

260 starsRust

I built a PHP-to-native compiler (written in Rust); now it runs DOOM

by nahime·Apr 3, 2026·3 points·3 comments

AI Analysis

●●●BangerWizardryZero to OneRabbit Hole

Compiles PHP to native ARM64 and renders DOOM E1M1 at 15 FPS—yes, really.

Strengths
  • Packed classes, buffer<T>, ptr types extend PHP for systems work without abandoning syntax.
  • No interpreter, no VM, no runtime—produces actual standalone macOS binaries.
  • DOOM demo proves BSP traversal, collision, fog all work in compiled PHP.
Weaknesses
  • Compiles a PHP subset, not full language—real-world utility is limited.
  • macOS ARM64 only, no Linux or x86 support yet.
Target Audience

PHP developers curious about systems programming and compiler internals

Similar To

Zephir · HHVM · PHP-CPP

Post Description

Because obviously the first logical step after compiling PHP to ARM64 was rendering DOOM with it.

It renders DOOM E1M1 in real-time. BSP traversal, perspective projection, distance fog, sector lighting, collision detection, step climbing - all PHP, compiled to native, running at 15+ FPS. You walk around the actual shareware WAD.

I can hear you: "but does it run DOOM?". No, it renders DOOM. There's a difference. The imps are safe. For now.

Why PHP? PHP has a simple, approachable syntax that millions of developers worldwide already know. That makes it an ideal bridge to bring web developers closer to systems programming, native binaries, and understanding what happens under the hood, without forcing them to learn an entirely new language first.

Of course, PHP was never designed to parse WAD files or traverse BSP trees. To get here, elephc had to grow beyond standard PHP with compiler extensions: packed class for flat POD records (all the DOOM geometry - vertices, linedefs, sectors, segs - lives in these), buffer<T> for contiguous typed arrays (the hot-path storage that makes real-time rendering possible), ptr for raw memory access, and extern for calling SDL2 directly via FFI. You write PHP, but the data structures "perform" like C (not really yet ;)). You can find everything that's been added on top of standard PHP syntax here: https://github.com/illegalstudio/elephc/tree/main/docs/beyon...

PHP vs DOOM (Video): https://media.nahi.me/illegalstudio/elephc/elephc-doom-3d-mo...

GitHub: https://github.com/illegalstudio/elephc

If this made you smile, exhale sharply through your nose, or question my life choices, consider dropping a on the repo. It's how people find the project, and it makes me mass echo dopamine.

Similar Projects