How to develop a lightweight MVC standard _php tutorial in PHP

Source: Internet
Author: User

How to develop a lightweight MVC standard in PHP


Now that the MVC free Open source framework for PHP has been many, we do not need to develop a lightweight MVC to repeat the production of wheels, 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 standards, which are not industry standards, to qualify the problem domain of this minor solution.

  (a) Lightweight MVC definition:

1. The framework is non-intrusive to the application and does not depend on any interface classes

2. Frame 0 configuration, 0 annotations

3. Easy to use, easy to understand, not to be restful, lest complex

  (ii) Lightweight MVC interface:

1. The controller uses setter injection request parameters and supports level injection, such as: Book.title.

2. Controller uses getter feed data to view, in view can be directly taken to the corresponding property values, such as: ${property}.

3. The controller handles the request with any non-setter and getter functions.

4. Controller takes the function return value to control the jump, only allows to jump to another controller, does not allow a controller to correspond to two view.

5. The controller's reliance on the model is automatically assembled by the setter, including the dependence between the model.

6. Session parameters, such as: Loginuserid, also through the setter injected into the controller, if the request parameters injected into the Loginuserid, will also be overwritten by the session parameters.

7. View and controller one-to-one, through name Mapping, and support a variety of view template type extension, such as: JSP, Velocity, Freemarker, commontemplate and so on.

8. When there is no controller, view can execute, which is equivalent to an implicit controller.

9. The framework shall provide COC interfaces, which are based on rules that stipulate that a package name is model, a package name is a controller, a directory is a view, For example: Com.company.module.controller, automatically discovers the module, and loads the model in a singleton mode, loading the controller in prototype mode.

All in all, the interface has nothing in addition to setter and getter, and automatic mapping rules.

  (iii) Lightweight MVC access:

/HTTP hostname [: Port][/Application name]/module name/Controller name/function name. html[? parameter name = parameter value]

Note: square brackets are representative of the province

  (iv) Lightweight MVC implementations:

Implementations that meet the above interfaces are available.

  (v) Lightweight MVC Advantage:

The business logic does not depend on any framework and can be adapted to any framework without impacting the business code, and when the old framework is eliminated and unattended, it can be migrated to the new, more stable framework in the quickest way possible.

The ideal is beautiful, the reality is cruel, the above purely personal ideas, the reality of more difficult, with a good vision is always better.

http://www.bkjia.com/PHPjc/928041.html www.bkjia.com true http://www.bkjia.com/PHPjc/928041.html techarticle How to develop a lightweight MVC standard in PHP now there's a lot of MVC free open-source framework for PHP, and we don't have to develop a lightweight MVC to reinvent the wheel, the purpose of this article is to learn ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.