Now MVC PHP Open source free framework has been a lot of, we do not need to develop a lightweight MVC to repeat the manufacture of the wheel, the purpose of this article is to learn the structure of MVC and MVC ideas, so as to better apply the open source MVC framework.
Note: The following definitions are narrowly defined, and you can define your own criteria, which is not an industry standard, to qualify the problem domain for this secondary solution.
(i) Lightweight MVC definition:
1. Framework for application without intrusion, do not rely on any interface classes
2. Framework 0 Configuration, 0 annotations
3. Easy to use, easy to understand, do not engage in restful, lest complex
(ii) Lightweight MVC interface:
1. Controller uses setter injection request parameters and supports level injection, such as: Book.title.
2. Controller using Getter supply data to view, in view can be directly taken to the corresponding property values, such as: ${property}.
3. Controller uses any non setter and getter function to process requests.
4. Controller use function return value control jump, only allow jump to another controller, do not allow a controller corresponding to two view.
5. Controller relies on the model for automatic assembly of setters, including model dependencies.
6. Session parameters, such as: Loginuserid, also through the setter injection to controller, if the request parameters injected into the Loginuserid, will also be covered by sessions parameters.
7. View and controller one-to-one, through name mapping, and support various view template type extensions, such as: JSP, Velocity, Freemarker, Commontemplate, and so on.
8. When there is no controller, view can also be executed, which is equivalent to implicit controller.
9. The framework shall provide the COC interface, which is based on a rule agreement that a package name is model, that a package name is controller, a directory is view, For example: Com.company.module.controller, automatically discovers module, and load model in single example mode, load controller in prototype mode.
All in all, the interface has nothing to do except setter and getter, and automatic mapping rules.
(iii) Lightweight MVC access:
http://host name [: Port][/Application name]/module name/Controller name/function name. html[? parameter name = value of argument]
Note: square brackets represent the province
(iv) Lightweight MVC implementations:
Conforms to the above interface realization all May.
(v) Lightweight MVC Advantages:
Business logic does not rely on any framework, can fit into any framework without impacting business code, and can migrate to the new, more stable framework in the quickest way when the old framework is eliminated and no one is maintained.
Ideals are good, the reality is cruel, above purely personal ideas, the reality of many difficulties, with a good vision is always good.