Help me understand the MVC pattern of PHP 1. single portal: Is it true that none of the front-end user requests come in from this portal? This entry is usually index. php. how can this website be obtained? 2. is it a module that corresponds to a controller? If there is a user module that contains registration, login, and so on, is there a process of parsing the URL before arriving at the controller? Parse the URL to identify user requests. help me understand the MVC pattern of PHP.
1. single portal: Is it because none of the front-end user requests come in from this portal?
This entry is usually index. php. how can this website be obtained?
2. is it a module that corresponds to a controller? If there is a user module that contains registration, login, and so on, is there a process of parsing the URL before arriving at the controller? Parse the URL to identify the user's request. if it is a login request, it is forwarded to the user controller, and then the controller forwards the request to the model, I don't know if a module writes a class (model), which includes methods such as registration and login, or if a module corresponds to a controller, which contains classes such as registration and login separately?
3. after reading the frameworks and some projects written in mvc for a long time, I didn't see how MVC works. I jumped here for a while, but I really don't understand this process.
------ Solution --------------------
1. single portal: Is it because none of the front-end user requests come in from this portal?
This entry is usually index. php. how can this website be obtained?
The. htaccess file is usually used to control the transfer to the entry file. Of course there are other methods.
2. is it a module that corresponds to a controller? If there is a user module that contains registration, login, and so on, is there a process of parsing the URL before arriving at the controller? Parse the URL to identify the user's request. if it is a login request, it is forwarded to the user controller, and then the controller forwards the request to the model, I don't know if a module writes a class (model), which includes methods such as registration and login, or if a module corresponds to a controller, which contains classes such as registration and login separately?
Not a module corresponds to a controller, but a module can correspond to multiple controllers. this can be designed based on your own business. before arriving at the controller, there is indeed a process for parsing the website, this process is carried out in the single portal mentioned above. The website is resolved to determine which controller to use. The controller accepts the user data and calls the model to process the data. then, the controller sends the model processing result to the view (for example, registering and logging on, and the controller accepts the user name and password, then, the model is called to verify the user name and password, and the controller sends the verification result (successful or failed) to the view ). The registration and logon method you mentioned is actually the method in the controller (usually called action), but some login registration logics (such as data query) are completed in the model.
3. after reading the frameworks and some projects written in mvc for a long time, I didn't see how MVC works. I jumped here for a while, but I really don't understand this process.
The simple process in the framework is generally (of course there are other things in the middle, this is just rough)
Request-> go to a single portal-> route (the resolution URL you mentioned)-> distribute-> process request-> complete
------ Solution --------------------
M: model
V: view
C: control
3. after reading the frameworks and some projects written in mvc for a long time, I didn't see how MVC works. I jumped here for a while, but I really don't understand this process.
This is right!
The framework hides the links between modules and only exposes some links that can be changed to users. Writing a program in the framework is like answering a blank question.
This is why the framework is not recommended for beginners.
2. is it a module that corresponds to a controller? If there is a user module that contains registration, login, and so on, is there a process of parsing the URL before arriving at the controller? Parse the URL to identify the user's request. if it is a login request, it is forwarded to the user controller, and then the controller forwards the request to the model, I don't know if a module writes a class (model), which includes methods such as registration and login, or if a module corresponds to a controller, which contains classes such as registration and login separately?
The disadvantage of MVC is that the division of labor is unclear.
Currently, most frameworks place business logic in C and data table operations in M.
In the literal meaning of MVC, C is only responsible for control and has no direct relationship with the business logic.
If you use the existing framework, you will not write M. M automatically completes programming based on the involved database when creating a project in the framework. Your energy is simply to break down the business logic into controllers.
1. single portal: Is it because none of the front-end user requests come in from this portal?
This entry is usually index. php. how can this website be obtained?
A single portal means that all user requests are transferred from an interface file, and all user requests are transferred as parameters.
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