What is MVC Architecture ?



WHAT IS MVC ARCHITECHTURE ?

MVC stands for MODEL - VIEW - CONTROLLER and it is an architecture that seperates different logics of an application. The 3 different logics namely the Model, the View and the Controller have different roles in an application which will be discussed below

In short, a View is something a user sees when they log on to the website. View gets generated when a Controller communicates with a Model and sends data recieved . 
When a user opens browser and types a website address into the search bar and hits ENTER, the request gets sent to the CONTROLLER gathers the required data needed for the route using the MODEL and then throws the data to the VIEW which then gets displayed to the users.

The MCV architecture can be used with many different programming languages like ASP.net , JavaScript and PHP. But here specifically, we will discuss things based on PHP and to be more precise, Laravel, A PHP framework.
If you want to learn about some other programming language, don't worry, the concept of MVC remains the same no matter what language it is.

WHAT ARE CONTROLLERS ?

As discussed above, a CONTROLLER is what interacts with the MODEL to fetch the data and display it to the user. 
It acts as a co-ordinator between the VIEW and the MODEL. Controller have a two way communication, that means, it recieves the data from VIEW (What a user wants to be displayed), then communicates with the MODEL to fetch that particular data and then after the data is fetched, communicates back to a VIEW to send all the data recieved.


WHAT ARE MODELS ?

Models are responsible for managing the data of an application.It can manage offline data or the data stored inside of a database. All the data requests are sent to the MODEL for it to process before it sends back the processed data to the CONTROLLER. 

WHAT ARE VIEWS ?

VIEWS serve the user. Suppose you visit a site, say, example.com/users, as soon as you hit RETURN, the request gets sent to the controller that then communicates with model to gather all required information for that particular route and sends it back to the route namely /users and then everything gets rendered and you see the users page of the website.


We will discuss how we can use MODELS, VIEWS and CONTROLLERS in Laravel in a later post.

Comments

Popular posts from this blog

Getting started with Laravel | Laravel Part - I

What is Vue.js and how to get Started with it