We are using CakePHP v4.x on a LAMP environment and would like to implement as 3-tier architecture such as
a) Presentation Tier
b) Application Tier
c) Data Tier
So would you able to guide any reference or advice that, how to implement it.
For your information:
a) Data tier will be the CakePHP database
b) Application tier will be the CakePHP application c) Not sure, what will be in the presentation tier?
Question?
In a three tier architecture, the presentation tier never communicates directly with the data tier; in a three-tier model all communication must pass through the application tier. Conceptually the three-tier architecture is linear. However, the MVC architecture is triangular: the view sends updates to the controller, the controller updates the model, and the view gets updated directly from the model.
You are mixing two different concepts, architectures and programming/design patterns. CakePHP would usually be the business tier in a 3-tier architecture, and in that scenario it’s completely irrelevant what design pattern it uses.
A simple example of a 3-tier web application architecture would be a Vue.js GUI frontend application (presentation tier), a CakePHP API backend application (business tier), and a MySQL database (data tier). In that example all 3 tiers could exist independently from each other on separate servers.
Thank you and correct me, if I’m wrong on this scenario please
Use any other user interface UI on the presentation layer and call to backend CakePHP [e.g. via API] to manage the request and response through presentation layer to client browser.
CakePHP will be in the business layer and request and response will be via API between presentation and business layer. So CakePHP cannot be split the programming/design pattern into separate servers due to MVC patterns.
This kinda sounds like you seem to mix up architecture and design pattern again. The 3-tierarchitecture has nothing to do with patterns such as the 3-layer MVC design pattern, the former describes a (typically client-server) architecture with three logically and physically separate units of computing, the latter describes design patterns that could be used to build a single tier. MVC is a pattern that can typically be found in the presentation tier as well as the application tier.
You’ll find many resources on the web and elsewhere that do get that wrong, they talk about layers and tiers as if these are interchangeable terms, but that’s not the case, a tier is not only logically separate, but also physically, and a layer is logically separate, but not necessarily physically. So long story short, a layer can be a tier (depending on the used technology), or, which is the common case, part of a tier, but a tier cannot be a layer.
Splitting layers of a PHP web application framework into tiers, is just… it doesn’t fit, that’s just the nature of the technology, and not specific to MVC designs. Just think about it, how would a PHP based model layer on a separate tier work? A model cannot do anything on its own, there would need to be a PHP script that accepts requests and delegates the work, at least a front controller, and off we go, we’re creating multi-layers again.