Can I use Struts as a backend and PHP as front end for a web application? If yes, what may be the implications.
-
1Not a good idea. Need some homework.Adeel Ansari– Adeel Ansari2008-12-23 03:22:28 +00:00Commented Dec 23, 2008 at 3:22
-
This question was from 2008 and there's no user account active associated with it. May want to remember that if you're expecting someone to accept an answer..!Fergus In London– Fergus In London2012-11-25 18:21:48 +00:00Commented Nov 25, 2012 at 18:21
-
Appears Arjan has decided to edit the title of the question for no reason... Bumping this up 4 years. Most pointless edit ever.Fergus In London– Fergus In London2012-11-25 18:22:56 +00:00Commented Nov 25, 2012 at 18:22
4 Answers
The first thing to came to mind is Quercus (from the makers of the Resin servlet engine), as Jordi mentioned. It is a Java implementation of the PHP runtime and purportedly allows you to access Java objects directly from your PHP (part of me says "yay, at last").
On the other hand, while I have been itching to try a project this way, I would probably keep the separation between Java EE and PHP unless there was a real reason to integrate on the code-level.
Instead, why don't you try an SOA approach, where your PHP "front-end" calls into the Struts application over a defined REST or SOAP API (strong vote for REST here) over HTTP.
http://mydomain.com/rest/this-is-a-method-call?parameter1=foo
You can use Struts to build your entire "backend" model, dealing only with business logic and data, and completely ignoring presentation. As you expose the API with these URLs, and you are basically building a REST API (which may come in handy later if you ever need to provide greater access to your backend, perhaps by other client apps).
Your PHP application can be built separately (and rather thinly), calling into the REST API (perhaps using Curl) as if it would call into a database or some native PHP class library.
Anyway, that's what I'd do. But, if you do use Quercus, please post how it went.
2 Comments
I don't know much about Java, but I remember running into Quercus a while ago. It's a 100% Java interpreter for PHP code.
So yes, you could have PHP templates on your Java app. Update: see Quercus: PHP in Java for more info.
Comments
I think what you mean is you want to use PHP as your templating language and structs as your middleware (actions etc).
I would imaging the answer would be no, not without some kind of bridge between the structs session and the PHP.
If you say change x to 3 in java in a structs action, you couldn't just go <?php echo x ?> or whatever to get the value out, you would need to transfer that information back and forth somehow.
Submitting would be OK though, I would imagine.
Not recommended though.