PHP MVC CodeIgniter Laravel Core PHP MORE

PHP MVC Tutorial


The Model-View-Controller (MVC) pattern, originally formulated in the late 1970s. It is an application design pattern that separates the application data and business logic (model) from the presentation (view). The controller mediates between the models and views.

Advantages:

Advantages of this architecture is reusability of code, data security and better application performance. In theory, a well-developed MVC system should allow a front-end developer and a back-end developer to work on the same system without interfering, sharing, or editing files.

Visual Representation for Data flow of MVC Architecture represented below:

Model:

Model is the name given to the component that will communicate with the database to manipulate the data.
It acts as a bridge between the View component and the Controller component in the overall architecture.
This is responsible to manage the data. It stores and retrieves entities used by an application, usually from a database, and contains the logic implemented by the application.

View:

The view is responsible to display the data provided by the model in a specific format. This is responsible for mapping graphics onto a device. A view attaches to a model and renders its contents to the display surface and formats the data to be presented to the user, in a web application as an html output.

Controller:

A controller is the means by which the user interacts with the application. A controller accepts input from the user and instructs the model and view to perform actions based on that input.
It handles the model and view layers to work together. The controller receives a request from the client, invokes the model to perform the requested operations and sends the data to the View.
controller is responsible for mapping end-user action to application response.