tags:

views:

736

answers:

6

I'm looking at various PHP compilers that turn PHP into native ELF executables. So far, I know of PHC and Roadsend.

Do you know of any others? Do you have any experiences to share? Note, I'm interested in any PHP compiler, not just those that are Zend specific.

If you are using one of the compilers linked above, I'd greatly appreciate any feedback that you care to share.

A: 

I had actually researched this for some code at work a short time back. While I did find a couple that said they could (sorry, don't have the links with me at the moment), I do believe that zend, the php people, have a compiler in their arsenal of products.

Regards,

Jeff

numberwhun
That allows for tinkering of intermediate output and produces optimized code (similar to gcc -O3)? Zend internals are far from ... optimized ... if you've ever had a look at the source.
Tim Post
I want something that takes PHP, converts it to C (probably C++) and then gives me plenty of room to specify my own optimizations and platform, or even the ability to leverage llvm to do such optimizations for me. I guess, it just doesn't exist yet :)
Tim Post
A: 

Phalanger?

Granville Barnett
A: 

I don't know what an ELF executable is, so I suspect this answer won't be helpful, but you never know: for a windows .exe I've used Active Site Compiler. It supports php, but there are some issues that you have to work around, especially if you're doing OOP things, so I can only mildly recommend it.

sprugman
ELF executable = Linux program. .exe = Windows program. Something that compiles PHP to an .exe on Windows could (very easily, probably) compile it to a program on Linux, but I have mixed feelings about ActiveState. But I imagine it works.
Chris Lutz
It's ActiveSite by a company called Intorel, not ActiveState, the makers of Komodo, etc. And I don't have mixed feelings about 'em, I hate 'em -- terrible service, and we have to hammer on it to get it to do what we want, but it does do it. :)
sprugman
Wow, I didn't know there were two of them. That's even worse! :P Though, in fairness, I think the question we should be asking is perhaps "Why does one need to compile PHP?"
Chris Lutz
+1  A: 

I do not have any experience compiling PHP to ELF executables, but you can try http://php4mono.sourceforge.net or similar projects (IronPHP 0.0.1) to compile PHP to Common Intermediate Language (.NET/Mono bytecode) and run on .NET or Mono VMs. Mono 2 also now offers full ahead-of-time compilation with the --aot switch, so you may be able to jigger that up to produce a native executable. Worth a try, perhaps -- Mono is really cool and even if this doesn't work, it's good to learn more about Mono.

Good luck.

EDIT: Per your comment on numberwhun's post, I don't know of anything that will translate your PHP to C. There are such programs available for Python, however: Cython and Pyrex. If your application is somewhat trivial, perhaps a port is not out of the question.

cookiecaper
+2  A: 

Are you looking for a bytecode translator or an ELF generator ? If you are looking for the second , take a look on PHC

Jorge Niedbalski R.
I have been looking at phc, Paul is doing a really good job advancing it. Yes, I need an actual ELF generator that allows for some optimizations.. I was hoping to find something using llvm or similar.
Tim Post
I only know PHC and another irrelevant projects and this is a really necessary tool. I will continue exploring another projects. If you really are insterested on this topic you can learn more about how to extend gcc with a frontend.
Jorge Niedbalski R.
+4  A: 

New: Facebook's HipHop

philfreo