Can you briefly explain MVC? The simpler the better
滿天的星座
滿天的星座 2017-05-16 17:06:26
0
17
1321

I recently planned to learn the PHP framework, only to find that my previous understanding of MVC was very superficial. But looking at Laravel's documentation, I'm still confused about MVC

滿天的星座
滿天的星座

reply all(17)
Ty80

C and V are human-machine interfaces, C is the functional part of the human-machine interface, and V is just the presentation form. It can still run if it is changed from graphics to command programs, but it is not intuitive. On the one hand, M is a resource for C scheduling. On the other hand, M is a part of the program that is not directly related to human-computer interaction. It often needs to be driven by C, but once driven, it can run independently. Many times when people talk about MVC, they underestimate M, thinking that it only encapsulates data and is static. In fact, this is only true when the logic is relatively simple. At this time, it seems that the logic can be stuffed into C. But in general, compared to M, C is very light because it is only responsible for human-computer interaction, while M is the main part of the program.

淡淡烟草味

MVC
M--Model, usually deals with the database.
V-Output to front-end users.
C-controller, used for process control, mainly coordinates M and V.

世界只因有你

When a customer goes to the restaurant to order, when the customer has ordered, the waiter has to tell the waiter, who then tells the chef.
M--Dish
V--waiter(menu)
C--cooker

M (dish) should deal directly with the kitchen, then the kitchen is the Service in the project.

Also: Some relatively low-end restaurants will use the waiter and the waiter as one person.
This is how to write business logic in JSP in JAVA projects.

Some lower-end restaurants have only one owner, who is also a waiter, food server, and cook. .
This is how to write data operations in JSP.

So in a high-end restaurant, there will be a variety of roles, which are extremely subdivided. Improve efficiency and improve maintainability. This is why there are so many interns in large restaurants.

左手右手慢动作

The boss said that he wanted to see the sales situation this month. This is a request. So you (C) accepted the request and asked each business department (M) of the company to provide all the sales data for this month, and then briefly organized the data and gave it to the boss's assistant (V). The boss' assistant uses these organized data to make charts and pie charts by department and submits them to the boss.

过去多啦不再A梦

view: handle user requests
controller: handles front-end requests and initiates database requests
model: handle database requests

黄舟

view: Display page
controller: processing logic
model: Process data

刘奇

The key to mvc is routing! ! ! , Don’t understand routing? ? ? Just split the url address, and you will gradually understand the remaining ones after you have written the additions and deletions of several controllers

So when we study MVC and routing, we just need to dismantle the URL address and call it a day!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template