phpcompilation

Compiling PHP Into Standalone Executable (Faster?)


I have a PHP script I'd like to compile into a standalone command-line executable for running on Linux.

Is this realistic? Are there compilers for this?

I know that there are PHP compilers around, but my question is oriented more to whether it is of advantage, and which is the best compiler to use.

Will it be faster or slower than running it through PHP? If it would speed up my script then that would be great, since it does a lot of processing (lots of loops and math) and takes an hour to run.


Solution

  • My understanding is that HipHop compiles to C++, not C, and that the process is quite easy. FaceBook has applied it to vast amounts of code.

    I'm not sure you get a .exe, but OP only wants "faster". He might get quite a good speedup; HipHop compiled-code averages only a factor of 2 or so faster, but that's because much of PHP execution is really library calls. He might get pretty good speedup on his computation part, if the HipHop compiler can figure out what the data types are in the computation code. He might have to modify his code somewhat to make this clear to the HipHop compiler, by not using his computation varaibles for anything but computation but that should be only a minor source code change. I'd expect the HipHop site to contain hints about what to do to speed up HipHop compiled code along these lines.

    All of this is educated guess based on what I understand and not actual experience. YMMV.