PHP Running on Java

I found an interesting project, quercus that compiles PHP to Java Bytecode allowing it to run ontop of the Java Resin Application Server. It has a couple neat features, one being PHP6 compatible unicode support, the other being easy integration between Java and PHP code.

It also seems to perform well, implements a large part of the PHP api, and lets you implement anything your missing just be writing a new Java Class.

It will be interesting to see if a project like this can actually take off.

Posted in PHP

8 thoughts on “PHP Running on Java”

  1. I attended Scott Furguson’s talk at the NY Java SIG last March when he gave a presentation titled “Implementing PHP in Java (Quercus) with the Resin App Server.” (

    Sam Heisz also presented “Quercus – A 100% Clean Room Implementation of PHP in Java” at NYPHPCon last June. (

    It seemed like an interesting idea at first, but after Scott’s presentation (I didn’t attend Sam’s) I was left with doubts about whether it was a good idea. The database connection pooling and session clustering ideas are interesting, but the tradeoff is that you now rely on PHP extensions rewritten and maintained in Java independently of their original C development trunks.

    As far as running PHP in other JEE app servers… BEA made some noise about their implementation ( and I had written up some notes about how to make WebSphere and PHP play nice [which includes a few more of my thoughts on Quercus] (

    I may take another look at it though, since it seems to be quite actively developed. Did you get a chance to try it out?

  2. Too bad only on Resin Professional edition we can compile PHP scripts into Java classes.

  3. Pingback:

  4. William: I’m not sure what the deal with that is, the code is all GPL so unless the professional version contains an extra module it should be easy enough to patch the compiling one.

  5. Daniel: I’ve only done some basic trying out of things. I’m actually more interested in using Quercus outside of Resin, i’ve been looking for a language to embed PHP in to do a bit of experimenting, but I haven’t wanted to write a new SAPI in C. I also have a couple PHP/Java integration projects (if they are approved) coming up so I might end up using Quercus quite a bit, assuming of course that I can get Quercus running on JBoss.

    Extensions in Java instead of C are an interesting tradeoff. It means you have to reimplement everything you want to support, but it also means you don’t have to worry about thread safety, mismatched memory models etc. I guess in theory you could use JNI stuff to talk to the C directly but for the majority of extensions it will be quicker to just port the code.

  6. Interresting, PHP on Java…

    Seems to defeat the purpose though, as Java’s strength is it’s protective type and syntax checking. It’s weakness the speed of execution due to all the checks. PHP’s strenght is its lack of type checking that results in excellent run-time speed and ease of coding. Weakness is no type checking and promotes terrible programming practices. Seems like PHP and Java are polar opposites. Combining them as in PHP interpreter running on top of Java just slows things down while providing little gains (platform independence to a certain degree?)…. Is there something I’m missing?

  7. Ivar: well the biggest benefit is it makes it easy to access Java Classes in your php code. So you can use Java as a backend language and PHP as a frontend. If you have a large java app server cluster it can also make deployment easier.

    I mainly care about it though because it makes it really easy to write a custom PHP extension its just a Java Class, so you can play around with multi-threaded PHP etc.

Comments are closed.