|
From: <php...@li...> - 2009-08-12 11:25:36
|
Hi Jost & all, I have to build a standalone, multiplatform PHP application that needs to use a number of java classes in both the "business" logic (e.g. the cryptography package from Bouncy Castle) and the graphical user interface (3rd party UI components). While being proficient in PHP the same cannot be said for Java, so I've being researching a good "hybrid" solution to get the job done and am currently focusing on a Java Swing front-end calling a PHP-equipped Jetty (http://jetty.mortbay.org/jetty/) on localhost. Specifically, I'd like to visually create the GUI with the NetBeans IDE, register the appropriate Event Listeners and implement all non-trivial (or forcibly Java) event-handling code in PHP, and I am struggling to understand strengths and weaknesses of the available options ... following is the list of alternatives I've come up with until now: 1) Just make an HTTP request from the event method to a PHP script on the Jetty back-end, where PHP can interact via PJB with any needed Java classes or simply make use of all its built-in functionality to generate a response. This solution implies I have to manage all response data and interface navigation in Java; also, there won't be any continuation passing between the Swing front-end and the PHP back-end, resulting in a somewhat less efficient interaction; 2) Write Java code using JSR 223 and PJB to call PHP classes/methods on the Jetty back-end. Still need to write Java code, nonetheless it looks like a better solution performance-wise: problem is, to date I didn't manage to call PHP user functions/classes from such an application - I can run the phpversion() sample provided, but that's it. Probably my fault, anyway I'd welcome a more complex example; 3) Expand the example in http://php-java-bridge.sourceforge.net/pjb/standalone.php so the Swing application makes HTTP calls to Jetty's PHP scripts. Instead of returning a response like in 1), the PHP code interacts with appropriately exposed application methods. I believe one could, to a point, even control the interface navigation from PHP in this way. Are there other alternatives to consider (I may be missing even the simplest, most elegant solution)? Regards, Massimo |