Technology of the day: Bridging Java and PHP

22 May 2007 » IBM, Java, PHP, WebSphere

Last summer I put together a list of Options for using PHP with WebSphere. One of the approaches I mentioned, but didn’t elaborate on, was to use a PHP-Java bridge.

In the time since I wrote that post, and particularly in the past month, there have been several items published which demonstrate the value of this technology. I still need to delve deeper, but here’s a quick summary of what’s going on.

What it is
In essence, a PHP-Java bridge enables PHP developers to access Java code from within their applications and vice versa. The benefit is that you can reuse libraries or services deployed on one platform from code that exists in a different environment.

This differs from the standard approach of using an HTTP server front end to route individual requests for PHP scripts or J2EE applications. The PHP or Java application can instead call the other without the HTTP server’s involvement.

While you can always use Web service APIs to communicate between your applications over HTTP, PHP-Java bridges provide a method to access the external application’s API directly from the source code. As such, they are much more efficient than traditional network calls.

How it works
Implementations enable one or more of the following techniques:

  • PHP running as a Web server module calls out to a servlet running on a J2EE application server.
  • A servlet executes PHP scripts via CGI.
  • PHP calls non-J2EE Java applications.

Where to get it
There are three major projects which implement this technology in varying degrees.

Find out more
The well documented open source PHP/Java bridge appears to be the most mature technology at this point. You’ll find more information via the related links section of the project page.

IBM developerWorks has posted the first installment in a “Develop with Java and PHP technology on AIX Version 5.3” series on setting up the requisite software in a Unix environment.

There don’t seem to be many details available about the Zend Platform Java Bridge, but I’m hoping to learn more when/if Andi Gutmans posts his presentation from JavaOne that he described in this blog entry.

There’s also a “Caffeinated PHP, Integrating PHP and Java” Webinar tomorrow which will describe Zend’s offering.

I’m not sure of the roadmap for the PHP Integration Kit and it hasn’t moved much since being announced as an alphaWorks technology last year.

  

4 Responses to 'Technology of the day: Bridging Java and PHP'

Subscribe to comments with RSS

  1. Nick said,

    22 May 2007 at 11:07 am

    The developers at Facebook released an open-source platform for cross-language development, called Thrift:
    http://developers.facebook.com/thrift/

    “Thrift allows you to define data types and service interfaces in a simple definition file. Taking that file as input, the compiler generates code that can be used to easily build RPC clients and servers that communicate seamlessly across programming languages.”

    IMO the major advantage of something like this over a specialized PHP-to-Java interface is the ability to quickly integrate with C++, .NET, Python or Ruby technologies down the road, without going back to square 1.

  2. David Dossot said,

    28 June 2007 at 4:26 pm

    I am surprised that you do not mention Quercus, a pretty neat PHP implementation in Java that Caucho releases as an open source project.

    D.

  3. Daniel Krook said,

    29 June 2007 at 9:54 am

    Hi David,

    I addressed Quercus as well as BEA’s PHP interpreter which has been written in Java in the original Options for using PHP with WebSphere post.

    I also outlined some more of my thoughts on the approach in a comment at Joshua Eichorn’s blog.

  4. Tim Robins said,

    23 September 2009 at 1:06 pm

    good article on a PHP framework written in Java
    http://www.ibm.com/developerworks/opensource/library/wa-quercus/index.html