PHPMVC mode (1 ). PHP advanced programming learning notes 2014.06.18MVC (Model-View-Controller, Model-View-Controller) is a very common design mode that simplifies application development and maintenance. It is from PHP advanced programming learning Notes
Model-View-Controller (MVC) is a very common design mode that simplifies application development and maintenance. It logically separates applications into parts. The model module is responsible for the application business logic, encapsulates the methods for accessing the database, and provides a reusable class library. The View section controls the appearance of data and provides a mechanism to collect data from users. The controller is responsible for connecting all the items, collecting data from the view, and determining the execution logic of the program. Call the model mechanism, parse the returned data, and submit the data to the view to display it to the customer. Five shutdown factors should be taken into account when selecting a suitable framework: architecture, documentation, community, support, and flexibility.
Typical MVC-based workflows
The designer creates a static and independent prototype design based on the existing business needs and the functions required by the application. Then, it is reviewed by the developer. Developers are responsible for ensuring that all required functions are feasible. if developers do not find any problems, they will create a development plan, including the API model, then it is handed over to the integration personnel (responsible for the controller layer ). If there is a problem with the prototype, the project will return to the designer's hands and continue the previous process.
After the prototype and API model are ready, the integration starts. The integrator will study the prototype design, convert it into a template language, and integrate the design into the site URL structure. Then write the controller, which distributes requests across the WEB server and the model information they need to manipulate. After the result is generated, the view is obtained and output, and the controller provides data for all dynamic content.
Finally, after the API model is fully implemented, the application can be handed over to the tester. If model developers strictly follow the API to write code, and the integration personnel write controllers according to the specifications, the test will proceed smoothly.
MVC application
The application portal. the MVC site usually implements a core script used to process requests on the WEB site. This file is called a boot file. The boot file initializes the framework, including automatic loading of classes, reading configurations, parsing URLs to models, filling in encapsulated request information, initializing controller programs, and other operations.
After the boot is complete, the front-end controller is instantiated and takes over the running of the program. The front-end controller class is a built-in class responsible for interpreting request variables. it routes client requests to a method on the Action Controller. this method is called an action and the action is responsible for implementing all the functions. This method will instantiate the model class, parse the View template, and output the results.
A model generally does not follow any specific structure, but exists in a public position, and all of them may be automatically loaded by the framework. A model is a tool class that provides the required data operations and parsing capabilities.
A view is a template and can be written in any template language. The purpose of a view is not to include any type of processing logic or data operations in the view, and only output data provided by the controller. The selection of template language (such as FastTemplate/Smarty) depends on whether it can be integrated with the target framework.
The Model-View-Controller (Model-View-Controller) is a very common design mode that simplifies application development and maintenance. It starts from...