简体   繁体   中英

How to build n-layered web architecture with PHP?

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 because 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?

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?

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM