PHP layered Mode
This text, written on May 1, at that time for some purposes, learned PHP, on the T-line developed a bit.
about layering mode, the first to learn C #, in touch with the three-tier architecture, MVCinJava , and the multi-layered architecture ofJava , there were Model1,model2before MVC . Today I want to write php, want to follow the path in Java , although all claim to object-oriented language, but the way is still different.
The core idea of layering should be decoupling and each level.
Multi-tiered architecture in Java:
Data persistence layer:DAO(data?access?object) or also defines a Idao interface; Data Access objects have no business logic, and CRUD for each table or entity . Frames are,dbutils (not on frames, toolkits),hibernate,ibatis->myibatis , etc.
Model layer, there are people called entity entities also called Beans, although it can be a bean, the individual thinks the Bean concept is not accurate, theBean concept is broader. This layer runs through the entire system, andDAO transfers the table data to the model object. With the model carries data transfer. This layer is intended to be object oriented.
Service layer, Business Logic layer: Responsible for system logic, control transactions, etc.; Call DAO to complete data persistence. Among them Web?service,cxf,Hessian is related to this layer of technology.
The web layer, which shows the data interacting with the user, can be performed by the servlet,JSP(also compiled into servelt afterjsp ) , using struts The web layer can divide the Action layer, distribute the user request to invoke Service layer logic, distribute the processing result data to the JSP,servlet.
In PHP, the view layer has a template to act as the core principle of the template is the substitution character. One months later, this PHP is as hard to talk as C #. But I can still read the PHP code.