Early Days - PHP JavaBridge and WebSphere 6.1
I'm interested in integrating some quality PHP applications like Drupal with the J2EE/JEE enterprise applications I love so well in order to broaden collaborative offerings. The key barrier that I see is security integration, and the key to that session integration.
To that end I'm looking at the PHP/JavaBridge utility, and as a first effort have it running OK with WebSphere 6.1. Work's on a Windows box today because that's what I'm in front of, but no real limits to running on Linux. Documentation is short and my understanding is limited at this point, but here's what we have:
- WebSphere 6.1, running inside my favorite Eclipse environment in the form of Rational Software Architect, and configured to listen on port 9060
- A Dynamic Web (JSP) project configured in the c:\Projects\JavaBridge\WebContent directory
- PHP 5.2.3 installed in c:\PHP. I've configured it to work with Apache 2.2 but am not using Apache in this first cut
That's all. Next steps will be to bring Apache into the mix -- the short summary is that things work but PHP is slow running directly from the servlet container. Probably because that's a bad idea.
Here's the integration steps:
- Download the latest PHP/JavaBridge from SourceForge and unzip it. I used php-java-bridge-4.2.2_j2ee which is an August 07 development version.
- Import JavaBridge.war from the unzipped folder into your RSA or Eclipse workspace, creating a WAR project and an EAR in the process.
- Make sure your project builds OK. You probably will have to adjust the facets to use a Java 5 compiler (I think the Bridge wants 5, and if it doesn't you should, and WS6.1 won't use 6)
- Make sure RAD or Eclipse didn't overwrite your deployment descriptor (web.xml). Mine did and it cost me an hour. If it overwrote, fetch the original out of the original WAR file and paste it in.
- Find the critical php_exec element in the deployment descriptor and make sure that it points at your PHP installation. Remember that regardless of windows conventions the slashes should be forwards and case matters. Mine looks like this:
<!-- Your php binary. Default is /usr/bin/php-cgi or -->
<!-- c:/php/php-cgi.exe -->
- Locate the Settings.php file in the WebContent directory of your WAR per below. Edit the "require_once" PHP directive to point correctly to your host and port where your servlet container is running. Remember, this is for the non-Apache direct service from the servlet container technique. The Bridge seems to reuse this require_once over and over to get its home port and host
$System = new JavaClass("java.lang.System");
- Fire up your WebSphere server and, assuming you are on port 9080 on the local host, browse to:
You should see a display like this:
- Try some of the examples.
I find that:
- Test and general php info fails, probably because it's a call to test.php, which isn't in the WAR. No big deal
- PHP/Java Servlet configuration proves the pudding! Should look like this:
- The Session Sharing app, which is the heart of my interest, kicks an integer back and forth between PHP and JSP programs, incrementing it each time.
The bad news is that the PHP call takes 7.8 seconds and the JSP call 0.2 seconds!
- The NumberGuess applications in both environments work fine, as does the PHP Excel automation. The final entry requires a JAR which I haven't deployed.
But -- it works!
Next steps will be an attempt to get the bridge to run thru Apache using the IBM plug-in for WebSphere, to see if that helps with the performance issues.
Then on to integrating the session identity information!