Page 1 of 1

making java and php work together

Posted: Tue Jun 05, 2007 1:40 am
by raghavan20
1. i have been thinking of using j2ee architecture along with php. since java could be run on application servers, they provide easier transaction control, object-level creation control & readily available ORM tools. may be i thought in a MVC framework, M can be in Java and V and C can be in PHP. PHP's ability to create quicker V and C is appealing to be used for frontend purposes. ok, but now how would i make these two languages communicate if both are using OO concepts.

we can model the business logic in session bean and Model is modelled using entity beans. may be we can put in a web service for all session beans. the session bean will control access to the entity bean. the message bean will be used in sending asynchronous requests which could be also made available through web service (like mailer or some process queue).

i have heard somewhere that objects in java can be serialized to stream of bytes or xml. if a java object could be serialized in xml and if PHP could make an complete object out of it, then it would be great, we can make them work easily. is this possible or there any other solutions around?

2. Is it generally a good idea to model the entire Backend/Model in some language and make it accessible via web service (proxies & facade could be employed at interface level). increasingly, now-a-days most of the applications had to intercommunicate and i think totally separating view and business logic would be a good idea.

3. i think the only problem with PHP is it could not be run on application servers thereby missing many important features required for a website having so many users. will something be changed in PHP 6 or later which might have something like servlet or ejb containers?

Re: making java and php work together

Posted: Tue Jun 05, 2007 3:50 am
by timvw
raghavan20 wrote: i have heard somewhere that objects in java can be serialized to stream of bytes or xml. if a java object could be serialized in xml and if PHP could make an complete object out of it, then it would be great, we can make them work easily.
That's exactly what a WebService (SOAP) should do, no? ((Deserialize) native objects into XML...). There are a couple of (imho) good tools for this available, eg: Apache Axis.
raghavan20 wrote: 2. Is it generally a good idea to model the entire Backend/Model in some language and make it accessible via web service (proxies & facade could be employed at interface level).
That depends on your requirements. Webservices aren't really efficient considering processor time or memory usage.
raghavan20 wrote: 3. i think the only problem with PHP is it could not be run on application servers thereby missing many important features required for a website having so many users.
I fail to see why php would have to run on the application servers? (Anyway, it's possible, eg: resion (caucho.com) has a server that allows you to run php too)