Can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?


I know that PHP is compiled to byte code before it is run on the server, and then that byte code can be cached so that the whole script doesn't have to be re-interpreted with every web access.

But can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?

7/15/2019 3:02:58 AM

Accepted Answer

After this question was asked, Facebook launched HipHop for PHP which is probably the best-tested PHP compiler to date (seeing as it ran one of the world’s 10 biggest websites). However, Facebook discontinued it in favour of HHVM, which is a virtual machine, not a compiler.

Beyond that, googling PHP compiler turns up a number of 3rd party solutions.


  • PeachPie GitHub
  • compiles PHP to .NET and .NET Core
  • can be compiled into self-contained binary file
  • runs on Mac, Linux, Windows, Windows Core, ARM, ...



  • compiles to native binaries
  • not very active now (February 2014) – last version in 2011, last change in summer 2013

Roadsend PHP Compiler


  • PECL extension of PHP
  • experimental
  • compiles to PHP bytecode, but can wrap it in Windows binary that loads PHP interpreter (see bcompiler_write_exe_footer() manual)
  • looks discontinued now (February 2014) – last change in 2011

Project Zero

  • Wikipedia, IBM
  • incubator of changes for WebSphere sMash
  • supported by IBM
  • compiles to Java bytecode
  • looks discontinued now (February 2014) – website down, looks like big hype in 2008 and 2009


  • compiles to stand-alone Windows binaries
  • the binaries contain bytecode and a launcher
  • looks discontinued now (February 2014) – last change in 2006


  • compiles to C++
  • looks discontinued now (February 2014) – last change in 2003
8/3/2019 5:35:33 AM

The short answer is "no".

The current implementation of PHP is that of an interpreted language. You can argue the theoretical aspects of the fact that any language can technically be interpreted or compiled, but as it stands, the current implementations are such that PHP code requires an interpreter to run, and the interpreter manages the executing environment.

To answer your question about uploading pre-compiled PHP bytecode, it's probably possible, but you'd have to implement a way for the PHP interpreter to read in such a file and work with it. With existing opcode caches out there already, it doesn't seem like a task that would reap much reward.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow