PHP Is Getting a Compiler?!
Chapters9
Announces that PHP will have two compilers: Elephant C and a Swoole team compiler, signaling a shift from pure interpretation to ahead-of-time compilation.
Nuno Maduro explains two promising PHP compilers (ElePHPant C and Swoole’s compiler), how they change deployment by shipping binaries instead of PHP sources, and what this could mean for PHP’s future.
Summary
Nuno Maduro walks through a bold shift in PHP’s trajectory: the language may gain not one, but two compilers. He contrasts the current PHP workflow—where the server reads PHP files and developers rely on tools like PHPStan for static analysis—with the potential speed and simplicity of deploying a binary. ElePHPant C is highlighted as an already advanced option, capable of compiling complex PHP features (enums, interfaces, final read-onlys) and even executing a Hello World example that prints code output from the binary. He also mentions a second compiler from the Swoole team, which reportedly uses a Zend library fallback to preserve dynamic PHP behavior when needed. The idea is to ship a pre-built binary to production, eliminating the need to deploy PHP itself or manage PHP versions. Nuno notes that both compilers bring pragmatic approaches to PHP’s ecosystem, aligning well with PHP 8.6’s evolving RFCs (generics, partial function application) and projects like FrankenPHP and Swoole. He also reminds viewers that dynamic features like eval pose challenges for compilers, with a practical demonstration showing undefined function eval in a compiled environment. Overall, the video casts a hopeful light on PHP’s compiler-enabled future while acknowledging the ecosystem’s reliance on dynamic behavior.
Key Takeaways
- ElePHPant C is already capable of compiling modern PHP features (enums, interfaces, final read-onlys) and can run compiled code locally, printing output to the terminal.
- Compiling PHP lets you ship a binary to production instead of source PHP files, eliminating the need to deploy PHP itself or worry about PHP version compatibility.
- The Swoole team is developing a second compiler that includes a Zend library fallback to preserve dynamic PHP behavior when needed.
- Both compilers imply a workflow where you build once, ship the binary, and execute directly, potentially simplifying static analysis and deployment pipelines.
- Dynamic PHP features like eval remain a hurdle for compilers, as shown by the test: eval isn’t available in the compiled environment without workaround.
- The ecosystem around PHP 8.6 (generics, partial function application, truesync RFCs) could harmonize well with compiler-based approaches and projects like FrankenPHP and Swoole.
- Installing ElePHPant C can be as simple as brew install illegal studio tap elephant C, making the experiment accessible to developers.
Who Is This For?
PHP developers curious about performance and deployment improvements, especially those exploring binaries over source-based deployments and those following PHP RFCs and compiler-related projects.
Notable Quotes
""What's up everyone? Apparently PHP is about to get not one, but two compilers coming to the language.""
—Intro mention of two upcoming PHP compilers.
""You build your application locally and then you ship that binary to production.""
—Core idea of compiler-based deployment.
""With a compiler, the old process is not only about to get simpler, but it's also about to get a lot faster.""
—Performance rationale for compiling PHP.
""You can actually have access to the assembly code that was created out of this process, which is awesome.""
—Insight into compiler transparency and debugging.
""If you want to see what's coming new for PHP 8.6, check out this video.""
—Encouragement to explore PHP 8.6 developments.
Questions This Video Answers
- how will PHP compilers change deployment and hosting
- what is ElePHPant C and how does it work with PHP
- can PHP binaries replace PHP source deployment in production
- what are the challenges of compiling PHP with eval
- how does Swoole's PHP compiler differ from ElePHPant C
PHP CompilerElePHPant CSwoole compilerPHP 8.6 RFCsFrankenPHPZend engineeval in PHPbinary deploymentPHP packagingPHP tooling
Full Transcript
What's up everyone? Apparently PHP is about to get not one, but two compilers coming to the language. PHP is an interpreted language like Python or Ruby, but now we are going to get a compiler as well, but not one, actually two. We are going to have ElePHPant C, but also apparently the Swoole team is making a compiler, too. Welcome to this video. My name is Nuno. Subscribe to the channel and let's dive into this. All right, one question you may have is what is a compiler? That's a good question, by the way. I'm going to just give you props on that one.
That's a good question. Now, first of all, let's try to understand what is the PHP current path. So, we have a request. Then we have PHP on the server. So, PHP gets actually shipped to the server. PHP will read a bunch of files to produce a response. This is like PHP currently. And if you want to have any sort of static analysis, you need to use tools like PHP Stan locally or in the CI, whatever. This is what PHP is today, and honestly, there's a bunch of time that gets lost here. Over time, the PHP team have developed some performance improvements here like with opcode and cheat and whatever, but a lot of time is actually lost during this process of reading PHP files and whatever.
Now, with a compiler, the old process is not only about to get simpler, but it's also about to get a lot faster. PHP would look a lot like languages like Rust, compiled languages. So, the way it works is super simple. You have a request. That request will hit a binary. Now, for production, you don't ship source code anymore. You just ship a binary. So, you build your application locally and then you ship that binary to production. As part of building your application, you also get static analysis on the process. So, you no longer have this ugly step of going to every single file to read the stuff.
You just produce the response directly with the binary and bam, done. This is like the most simplified explanation of a compiler that I will ever find on the internet. Now, what this actually means for PHP developers, if you end up using one of these two compilers, you actually just need to build your application code once and then you just ship the binary to the server or to your teammates. This could be really important as you don't have to ship PHP with it. So, today, for example, if I want to execute this Hello World, I need to ship PHP with it, meaning that I you need to use PHP to read this PHP file.
Now, with a compiler though, you just compile it once, and then you have the binary that you can execute just like that. And you just ship the binary. You don't need to include PHP on the process. You no longer need to think about PHP versions. You don't need to ship PHP to the server. You don't need to ship PHP to your teammates. It really just works. And one interesting thing here is that you can actually have access to the assembly code that was created out of this process, which is awesome. Now, my friends, over time, I have seen hundreds of attempts to make something like this, but I've actually tried that fairly complex example using very modern PHP.
So here we see enums, we see interfaces, we see final read onlys, we see a lot of stuff that typically it's not yet supported by some of those attempts in the past. And if I run this code, I've literally just compiled this 02 cars locally. I've compiled it and then executed and I can see the code being printed on the terminal. So I would say that at least this elephant C compiler is super advanced already and is actually working as expected. Now, my friends, of course, if you are using the eval or evil, as I like to call it, I don't think this compiler will actually work as expected.
Let's actually try it out. So I'm going to execute with PHP, so I get to see foo on the terminal. However, if I try to compile this, I see undefined function eval. So I honestly think that if this compiler, at least the elephant C, wants to support the PHP ecosystem, it will need to find a way or a work around around eval or any kind of dynamic behavior, just because the entire ecosystem relies on dynamic behavior today. And my friends, this compiler is actually stupidly easy to try it out locally. So you just have to type brew install illegal studio tap elephant C, and you got that installed in your laptop, my friends.
Now, elephant C, it's literally one of the compilers we are getting. We're actually getting two right now, and this one is made by the Swoole team. Now, we don't know much about this. The only thing I have discovered online is that besides having the app a path of the compiler approach, this new library from the Swoole team also have this fallback which fall backs on the previous dynamic nature of PHP. Now, this doesn't mean that you have to ship PHP to the server, but this compiler will also include something called the Zend library. So, we can fall back into the dynamic behavior if there is the need for it.
But, it ends up being an executable as well. So, we'll work just like the other compiler we just saw. So, we have two compilers coming in they both look awesome. And something I was able to discover is that the team behind this new Swoole compiler is also the team behind the PHP RFC truesync, which is another topic that we can literally make a video about that. Now, this is one more thing that the community is talking and trying to improve on the PHP ecosystem. And honestly, with PHP 8.6, 2026 is looking amazing for PHP. We're seeing generics being approached.
We see partial function application. We see a lot of RFCs that look amazing for the language. PHP foundation looks better than ever. And now we see the community trying to bring PHP to the little bit of the compiled side of languages. I think this is one of the biggest things that can potentially put PHP yet in another level. I think it's awesome that the community is trying to approach it in a very pragmatic way. I think it's like Swoole or even FrankenPHP potentially are trying to also support dynamic behavior of PHP. That's important making sure the ecosystem can also follow this compiler approach.
If you want to see what's coming new for PHP 8.6, check out this video. It's absolutely awesome. If you want to see why the PHP tooling is awesome, you can check out this video. Love you all. See you guys next time. PHP is an interpret interpret interpret interpreted language. Yeah, interpreted language. Oh my god. Interpret interpreted interpreted interpreted. [laughter]
More from nunomaduro
Get daily recaps from
nunomaduro
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.



