In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what the thinkphp controller is, the article is very detailed, has a certain reference value, interested friends must read it!
The controller of ThinkPHP is a class, which accepts the user's input and invokes the model and view to complete the user's requirements; the controller layer is composed of the core controller and the business controller, which is responsible for the scheduling control of the application, while the service controller is completed by the user-defined controller class.
The operating environment of this tutorial: Windows7 system, thinkphp v5.1, Dell G3 computer.
ThinkPHP is based on the MVC (Model-View-Controller, Model-View-Controller) pattern and supports multi-tier (multi-Layer) design.
MVC is a design pattern that forcibly separates the input, processing, and output of the application. Using MVC applications is divided into three core components: model (M), View (V), and Controller (C), each of which handles its own tasks.
Controller (Controller) layer
The controller of ThinkPHP is a class.
The controller layer of ThinkPHP consists of a core controller and a service controller. The core controller is completed by the App class within the system, which is responsible for the scheduling and control of applications (including modules, controllers and operations), including HTTP request interception and forwarding, loading configuration and so on. The business controller is completed by a user-defined controller class. The implementation principle of the multi-tier service controller is similar to the layering of the model, such as the service controller and the event controller:
Controller/UserController / / for business logic control and scheduling of users
Event/UserEvent / / for the user's event response action
The access controller Home/Controller/UserController.class.php is defined as follows:
Namespace Home\ Controller;use Think\ Controller;class UserController extends Controller {}
The event controller Home/Event/UserEvent.class.php is defined as follows:
Namespace Home\ Event;use Think\ Controller;class UserEvent extends Controller {}
UserController is responsible for external interactive responses, requesting responses through URL, such as http://serverName/User/index, while UserEvent is responsible for internal event responses, and can only be called internally:
A ('User','Event')
The default access controller layer is Controller, and we can adjust the settings as follows:
The default controller layer name of 'DEFAULT_C_LAYER' = >' Event', / / is changed to Event
So it's isolated from the outside.
The division of multi-layer controller is not mandatory, and it can be layered freely according to the needs of the application. In the controller hierarchy, you can call the hierarchical model as needed, or you can call different hierarchical views (topics).
In the three layers of MVC, ThinkPHP does not rely on M or V, or even only C or V, which is a very important user experience design in the design of ThinkPHP. Users only need to define views and can automatically identify them without C.
The above is all the content of the article "what is the thinkphp Controller?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.