What is Model, View & Controller to MVC Framework ?
MVC is a Software architecture and also known as Model-View-Controller. The model view controller pattern is the widely used Software architecture pattern for today’s world web applications. MVC pattern build on the basis of keeping the presentation of data separate from the methods. MVC build in three parts: Model, View and Controller.
In following figure shows the single flow layout, how to data interact and passed between each component, and how to component related with each others.
Model: The model is responsible for manage application data; it store and retrieve data entity which is used by application, usually from application database, and contain business login implemented by the application.
View: The view (Visual presentation) is responsible for display data which is provided by model in a specific format. Its same as usage with the template modules present in some popular web application such as Opencart, Joomla etc.
Controller: The Controller is responsible to handle the model and view work together. The Controller get a request from the user, invokes the model to perform the requested operations and send data to the view component. The view formats the data and to be presented to the end user, in a web application as html output.
Let’s take example of Opencart web application which also known as Open source application for make online store.
Opencart itself works with MVC architecture. It’s 100% Free Open source application for online store.
In opencart two main folders which contain MVC structure. 1) admin and 2) catalog. System, images & install folders are different from MVC. System folder contain library files , helper files , engine source etc. Images folder contains all images of website and using install folder user can install application on web hosting or local system.
Basic Opencart structure as given below
Admin folder contains main three folders (controller, model & view) which follow MVC structure. See below picture.
Same thing for catalog folder main three folders are controller, model & view. See below picture.
I hope this post will help to get how works MVC architecture with web application. Please share and comments for your feedback on this.