I had a short note in PHP, the language a lot of websites still run, and I wanted a program I could start on a machine that does not have PHP installed. The note prints Tea for two, then the sum of 2 and 3. elephc is a compiler that turns that note into a file the computer can run by itself. I compiled the note with elephc 0.27.7, the official Linux x86_64 release, on 13 November 2026. So, is elephc worth it? The new file printed both lines, and it did not ask for PHP when it started. Yes, for that small script. No, if this is the PHP your website already runs.
A compiler does the work before anyone runs the program. Ordinary PHP does the opposite. It reads the file again every time a page loads, and it decides some names only then. That second way is why a website can load a plugin whose file name is not written down until the request arrives. elephc wants the names earlier. That one difference is the whole decision.
What Is elephc

elephc (pronounced el-ef-see, like the letters L, F, and C) reads a PHP file and writes a normal program next to it, for a subset of PHP whose names it can see while it compiles.
PHP is still the text you write. The compiler is the extra program. The result is an ordinary file you start by name, the same way you start any other small tool. The project is under the MIT license, so you can read it, change it, and ship a program you built from it. Official docs describe it as a from-scratch compiler, not a copy of PHP stuffed into a larger file. If it accepts a line, that line becomes machine instructions, the steps the processor runs, rather than a script PHP has to interpret later.
I kept the test small on purpose. A function that returns Tea for two, a call to strlen on the word kettle, and a tiny class with one number all compiled. The function program printed Tea for two and then 6, which is the length of kettle. The class program printed 5. So this is not limited to a single echo. It is still not “any PHP file you already have.”

The left path is the one I would trust. The right path is the one that stops you, and it is the path a lot of real sites depend on.
How Do I Compile PHP With elephc
You point elephc at the file, then you run the program it wrote beside that file.
This is the note I saved as tea.php.
<?php
echo "Tea for two\n";
$a = 2;
$b = 3;
echo ($a + $b), "\n";Then:
elephc tea.php
./teaThe compiler printed Compiled 'tea.php' -> 'tea'. The program printed:
Tea for two
5The file it wrote was 813,616 bytes, about 795 KiB. A second note, a loop that adds the numbers from 0 up to but not including one million, compiled the same way. The sum was 499999500000, which is the right total. I ran that program three times. The wall-clock times were 0.0539, 0.0533, and 0.0535 seconds. PHP was not installed on this machine, so this is not a claim that the compiled loop is faster. Other people publish speed tables. Those tables are not this test. If you want the comparison, run the same file with php loop.php on a machine that has both, and time both yourself.
One thing I expected to fail did not. I put the text strlen in a variable and called that variable on the word tea.
<?php
$fn = "strlen";
echo $fn("tea"), "\n";It compiled, and it printed 3. A call through a variable is not an automatic wall. The wall shows up when the name of a variable itself is computed, or when the file to load is computed. I will show both of those in a minute, because that is the part that decides the tool.
If the fragment you compile uses eval on a string that is a fixed quote, the compiler still accepted mine. The string was echo 2 + 3; and the program printed 5. A regular-expression call was not tried on this machine, and 0.27.7 printed no warning about regex support for that file.
Does elephc Need PHP Installed
No. The tea program started and printed both lines on a machine where the php command was not installed.
That is the useful half of the test. I asked the system which shared libraries the tea program needs. A shared library is a separate file a program loads when it starts, and PHP would be one of those if the result were just a wrapper. The answer was not a dynamic executable. The file has no dynamic section and no list of shared libraries, and nothing in that check was a PHP library. So the result is not “PHP, hidden inside.”
There is a limit next to that good news. While linking, the step that glues the program together, the linker warned that host-name lookup functions inside a program built this way still want the C library’s shared files at run time. The warning named getaddrinfo, gethostbyname, and gethostbyaddr. My tea program never looked up a host, and it ran. If your script calls out to a host name, do not read “not a dynamic executable” as “this file will start on every Linux machine from the last decade.” Try it on the machine you mean to copy it to.
Compiling the note did not require an account, a key, or a sign-in. The compiler wrote a cache of its own runtime on disk, which is normal. A packet capture was not run here, so this is not a network-audit claim. I would still read a release before you trust it, the same way you would read any other compiler. The project page and the code are at elephc on GitHub, and the language notes are at elephc.dev. PHP itself, the thing this does not replace, is documented at php.net.
elephc vs PHP
elephc is the better tool when the script is finished and the names are written in the file. Ordinary PHP is the better tool when the script decides names while it runs.
I tried the two shapes that websites use all the time.
A variable variable builds the name of another variable at run time. This file does that:
<?php
$a = "tea";
$name = "a";
echo $$name, "\n";elephc stopped before it wrote a program. The error said variable variables ($$name) are not supported, because variable names must be known at compile time. Ordinary PHP would print tea. That is not a small syntax preference. It is a different time. Compile time is while elephc is reading the file. Run time is later, when someone starts the program or opens a page.
An include with the path stored in a variable failed the same way. I set a variable to tea.php and included that variable. The compiler said runtime-dynamic include paths are not supported, and that a path has to be a string it can finish before the program starts: a quoted string, a concatenation of those, or a constant. A path chosen later is rejected. Ordinary PHP includes that file with no complaint. A quoted path, which is the shape that error asks for, compiled here and printed the same two lines from tea.php.
| Job | elephc | ordinary PHP |
|---|---|---|
| Print a line and add two numbers | Wrote a program, printed Tea for two and 5 | Needs the php command |
| A function and strlen | Printed Tea for two and 6 | Works |
| A small class with one field | Printed 5 | Works |
| Call strlen through a variable | Printed 3 | Works |
| A variable variable, $$name | Compile error, no program | Prints the value |
| Include a path stored in a variable | Compile error, no program | Loads the file |
| Run the result with no PHP installed | Yes, for the tea program | No |
| A site that loads plugins by a name chosen per request | Not this tool | This is the normal path |
The speed cell is blank on purpose. I timed only the compiled loop. I will not borrow a multiplier from somewhere else and paste it next to a PHP run this machine never had.
Can elephc Replace PHP for WordPress
No. I would not point elephc at a WordPress tree and expect a site.
WordPress was not compiled here, and a four-line include is not a stand-in for a whole project. What I can say is narrower, and it is enough. WordPress loads plugins, themes, and drop-ins by names that depend on the request, the options table, and files that show up later. The include I did try, with the file name stored in a variable, never became a program. A site built that way will stop at the same kind of line, long before you get a homepage. The official elephc site is aligned with that limit: frameworks stay on PHP today, while static modules can be compiled. That hybrid path was not tried here.
There is a second reason, and it is not about speed. The PHP that runs your site is also the program you patch when a bug in PHP itself is the problem. Updating the theme does not change that program. That mix-up is the subject of PHP2Shell, from zero. elephc does not sit in that repair path. If the question is which PHP your server is running, php -v is still the command, and elephc is the wrong tool.
If you only have the finished program and you want to know what it does, that is a third job. A compiled file is a pile of machine steps, not the note you started from. rea versus Ghidra is the page for that, once the source is gone. Do not compile a site away and then hope another tool can hand you the original PHP back.
When Is elephc Not Worth It
Skip elephc when the next line builds a name you do not know yet, or when the machine that runs the script already has PHP and you only needed a page.
It is the wrong tool in four ordinary cases.
- The script uses variable variables, or it includes a file whose path is computed while the program runs. Both of those stopped in this test, with no program written.
- The thing you wanted was a WordPress, Laravel, or similar site. Those projects are full of the first case. Keep them on PHP.
- You need a host-name lookup and you also need the file to run on an older or smaller Linux than the one where you compiled. The linker warning is there for that case. Copy the program to the other machine and start it before you trust it.
- You wanted a speed number. I do not have one against PHP. A compiled loop of a million additions finished in about 0.05 seconds here. That does not tell you what your page will do.
It is worth installing when the script is yours, the names are already in the file, and the machine at the other end should not need a PHP package. The tea note is that shape. A function, a strlen, a small class, and even a call through a variable holding strlen were that shape too. Compile the file, run the program, and read the first error before you plan a migration. If the error is about a name that is only known later, stop. That script wants ordinary PHP, and elephc is telling you so in the compile, not after a user hits the page.
Common questions about elephc
Is elephc worth it
Yes for a small PHP file whose names are written in the source, because the program I compiled printed Tea for two and 5 with no PHP installed. No for a website that loads code by a name chosen at run time.
Can elephc compile WordPress
WordPress was not compiled here. An include whose path sat in a variable failed at compile time, and WordPress depends on that kind of load, so I would not try to replace its PHP with elephc.
Does elephc need PHP installed
The compiler has to be installed to build the program. The tea program itself did not need the php command, and it ran where that command was missing.
Is elephc open source
Yes. The project ships under the MIT license, which lets you read, change, and ship what you build. The code is at github.com/illegalstudio/elephc.




