Re: 100% Java Quercus PHP engine running in GlassFish Java EE 5 Application Server...

; Date: Tue Mar 13 2007

Tags: Java

In (web.archive.org) 100% Java Quercus PHP engine running in GlassFish Java EE 5 Application Server... is a bit of excellent news. Caucho, the maker of the Resin app server, has developed a pure-Java PHP execution engine. The engine is under the GPL and last fall I'd tested it using the Drupal content management system. Near as I could tell it worked fine, and it seemed that since it's under the GPL one could extract just the PHP engine and run it on other servers. But when I looked at the source it seemed possibly too intertwined with the Resin server. So I made a couple postings about this, and then let it drop as I had other priorities. Thankfully someone has looked into it.

Ludovic has tried a simple set of steps (see his blog entry) that takes a couple JAR files from the Resin distribution, installs them into a Glassfish instance, and suddenly you can run PHP natively in Glassfish. Cool. I'd think the same could be done for other appservers.

Quercus, Caucho's PHP engine, works by translating PHP code to Java code. It then compiles the Java to classfiles anc can execute it at the full speed of the Java VM.

PHP? Cool? Isn't this (java.net) java.net?

Yes, this is (java.net) java.net and I prefer Java as a language over PHP, especially as the PHP language is rather messy ... but ... it's undeniable that there are a lot of nice web app tools written in PHP.

What would a PHP developer have to gain by using this method? Quite a lot, actually. Quercus allows a PHP developer to access Java classes and methods .. which then means ones application can be architected to use PHP more for the presentation layer (where PHP shines) and use Java code as the backend (where Java shines). And it offers an integration route for a team that wishes to use multiple languages .. e.g. some Ruby or Python thrown into the mix of PHP and Java.

Additionally Quercus lets the PHP code run at the full speed of Hotspot with all the runtime optimizations which Hotspot can perform.

A few months ago I posted something like "who cares what language it is, so long as it's the Java VM underneath". That's still a very compelling argument to me. While the Java language has a lot going for it, obviously it isn't the be-all-end-all of programming languages. The Java VM has always offered the ability to host other languages besides Java, it only took until recently for us (Sun) to admit it. This makes it feasible to mix programming languages together in interesting ways, using the best language for each aspect of the problem you're trying to solve.

To a language author they can focus on implementing their language. They don't also have to become expert in the arcanery of virtual machines and interpreter design.

Source: (web.archive.org) weblogs.java.net

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.