controller -------------- > model ^ (3) ^ . | . (1) (3) | . | (2) view ----------------- > service
includeonly. Sets template variables. Can silently perform some business logic actions too.
- AJAX call. These calls will be available for integration purposes as well.
includefollowed by API calls.
Line (1) is dotted to point out that although it is the view that calls for the controller, usually it doesn't need to pass any specific input data. COOKIES/GET/POST data are grabbed by the
controller autonomously since they are superglobal arrays in PHP. Therefore a view usually only includes the respective controller in order to carry out a form submission and/or get its template variables. Indeed a view is just a template written in plain PHP.
includestatement at the beginning and some embedded PHP code that implements the server-side part of the presentation logic only.
This model securely suits Web 2.0 developments where business logic is split among client and server. It was inspired by a much-discussed Rasmus Lerdorf's article. There is no involved framework that implements this architecture, it's all standard plain PHP and judicious use of the file system.
Since this model is based upon web services, your web application will be fully interoperable from the outset, without any additional complexity or code duplication. The same ideas can be implemented in any HTML-embedded language, not only PHP.
Found here a sample PHP implementation about collecting people's contacts. To simplify matters, the following sensible choices have been made for implementing each part of the model:
- JSON web services
- the Prototype library to provide some HTML extensions (DHTML menu, client-side form sanitizing and validation, calendar widget, cross-browser AJAX support); PHP itself as a template language
- PHP Data Objects, an abstraction layer for data-access only and prepared SQL queries.
- the PHP standard data-filtering functions, for added security
For more details please read
PROJECT/NOTES.txtinside the people.tgz tarball.