views:

361

answers:

2

I'm dealing with the 3-tier architecture PHP website.

Now,i need to redesign it to suрроrt distributed n-tier architecture.After long hours of research i came to this solution: business logic should be separated into presentation and purely business logic tier to allow for n-layer architecture(user-interface,presentation tier,b.logic and data tier).I have decided to use РНР just for the presentation.In the business logic i want to use J2ЕЕ implementation technology instead of implementing it in PHP cz J2EE can provide much more essential container services which are essential for business logic,its robustness,maintainability and different critical business operations.

From your professional point of view,does it sound like a good way of redesigning the original website to allow for n-tier architecture considering the specifics of the website and the criticality of its operations?

+3  A: 

Everything you want to do is possible with Zend Framework. It follows an MVC architecture and has things like the Zend_Soap component for your services.There is no reason to build some multi-language application when you can keep it all within PHP. Why do you want to use Java so badly?

ryeguy
PHP is just as capable of this as Java. Zend Framework has been around for quite some time and is developed by the creators of PHP. Can't get more reliable than that. Regardless of your choice though, I would stick with one language. Even if one language is better than the other at a specific task, the difficulty of switching between languages outweighs the benefits.
ryeguy
What exactly do you need transactions for on the application level? Is there something your database cannot do?
ryeguy
Transactions are handled on the database level. It has nothing to do with J2EE or what language you choose. It has to do with your database, and pretty much any DB supports them. What exactly are you trying to accomplish with a messaging system? I think in general you're worried too much about the implementation instead of the end product.
ryeguy
JMS and MOM have nothing to do with the 'messaging' you're thinking of. It's basically just a wrapper around packet sending between processes. "Pushed messages" isn't any kind of technical detail. What is a pushed message? RSS? Email? This is possible with any language. You're honestly worrying too much about the technologies you're choosing. PHP is used by many large scale companies -- Facebook and Yahoo, and many more. If these two huge companies can use them -- which will probably be much larger than any company you and I will ever work for -- I'm sure it's good for your needs.
ryeguy
MOM isn't used for that type of thing, it's more for messaging between 2 server side processes. A server-push technology is Comet (wikipedia it), and can be implemented using long polling techniques using Jquery, for example.
ryeguy
I'm assuming you want to push each email to a queue and have an email daemon pop them off? To be honest, I'd just implement this using a simple database (keep things easy). But if you must use a queue, you could use beanstalkd (http://kr.github.com/beanstalkd/) or rabbitmq (http://www.rabbitmq.com/). These are both stand-alone queue daemons that have PHP interfaces. RabbitMQ is more robust and complicated. I hear that Twitter uses it.
ryeguy
I take that back: http://zendframework.com/manual/en/zend.queue.html
ryeguy
@ryeguy: have you been talking to yourself, or have some comments been removed?
nickf
@nickf I removed some of my comments
Alex
+2  A: 

From your description I understand the existing application runs on a LAMP stack. PHP integrates nicely into the LAMP stack and scales well with it. Why do you want to migrate this to a Java ecosystem? Reimplementing the business logic in Java means you throw away the essential working part of the existing app. If there already is a working business layer and DAL, why start from scratch again? Wouldn't refactoring be the smarter (and cheaper) alternative?

In addition, you claim J2EE will provide much better robustness and maintainability. How so? Maintainability is mainly a matter of code architecture and coding style. I am not aware of any pattern in Fowler's PoEAA that cannot be implemented in PHP as well. PHP also provides mature frameworks for UnitTesting, Continuous Integration, ORM, Dependency Injection, Message Queues, Webservices, Deployment, etc. to support your application development.

Sure, Java is compiled and supports multithreading and has a history in enterprise software architecture and I am not denying that it has language features PHP doesn't have. But the question is, do you need them for this project? And let's not forget that a programming language does nothing on it's own. It's the developer who creates the application and J2EE Spaghetti code is still Spaghetti Code.

Just my 2c though :)

Gordon
@Alex in regard to 1st comment: Based on the information given in your question, I'd say no, it would not yield any advantages or benefits to do it like you describe for the reasons I gave. But you are the architect for this project. You have all the information about it. If you and your client feel the project requires to be rewritten in Java, do it in Java.
Gordon
@Alex in regard to 2st comment: I agree with this statement but would not limit it to the presentation layer, but the backend as well. Also, basically all web apps are n-tiers. The UI lives in the browser but is rendered on a webserver. The webserver consumes webservices and fetches from RDBMs and authenticates users against LDAP, etc. PHP can handle all of that. So can Java. But like I said, you are the architect :)
Gordon
@Alex I think you are misreading the statement on phppatterns.com. The author doesn't want to imply PHP is only cheap, etc when used for the frontend. I agree to *"For enterprises looking for a cheap, solid, flexible and reliable means to construct their web presence, using PHP could well be the ideal choice, over expensive application servers, vendor lock in and closed source solutions"*
Gordon
@Alex How could I possibly answer this? There is way too many unknowns in your description. Like I said, you are the architect. If you are in doubt about your architecture, PHP or Zend Server in particular, give Zend a call and ask them. Zend offers commercial support for all of their products.
Gordon