MVC Structure

When we start learning a programming language, we see some structures and frameworks. MVC structure one of them and most popular structure.

What is means MVC?

MVC is an abbreviation of Model, View, and Controller shortly. All of the structures were named with the first letters of the words.

Which languages using MVC?

I don’t know all programming languages and I don’t research all of them. But, I saw MVC structure in the ASP.NET and PHP.

How it works?

It’s simple. End-user sends a request to the web server. The web server runs your language’s executable file. After then, the files of your project will be triggered. So far, already you know how it works.

1st step: The main file of your project call routing structure. Routing describes which controller will be triggered. This is named as the request.

2nd step: Controller structure calls the controller file and triggers it.

3th step: The method of the controller file triggered by the controller structure executes a code block. This code block calls model and view structure.

4th step: The model structure calls the model file and triggers it.

5th step: The model file collects data, process it, and return it.

6th step: The controller file keeps data returned from the model file in a variable.

7th step: The controller file triggers view structure and pushes this information into it: template file and processed data via the model file.

8th step: The view structure handles codes of the template file. In this step, response and final view are preparing for end-user.

9th step: The view structure returns the final view and response into the controller file.

10th step: The controller file responses the end-user browser with final view. This is named as the response.

end-user: a visitor who visits the website by the scenario.

Which frameworks using MVC in PHP?

I know PHP programming language at the work proficiency level. Well, it’s a simple question for me. Most of the popular macro frameworks use it: like Laravel, CodeIgniter, and Symfony. Also, a micro framework, Slim Framework supports it.

Advantages

  • MVC supports a team works. Who wants to be involved a project, he/she understands what code is where.
  • It’s a product of object-oriented programming.
  • Saving time and effort on big projects.
  • MVC can provides expandable structure.

For now, I said all pieces of information about the MVC in my mind.

Happy codings!