There are many systems in PHP that follows MVC (Model-View-Controller) architecture. It is a robust design pattern that separates data access, business logic and user interface code.
A typical MVC concept,
Model: consists of application data and business rules. It communicates with the database get the information. In Magento, we have these files under “Model” folder of each module in any code pool be it core, local or community.
Controller: mediates input, converting it to commands for the model. These files decides action between model and view files. They can be found under “controllers” folder of each module in core, local or community code pool.
View: output representation of data like rendered HTML. In Magento, these files resides under template at app/design and have .phtml extension. These files have combination of PHP and HTML code as well as $this object to refer to Model for data structure.
But Magento is based on more abstract MVC pattern. Refer the below diagram
- URL is taken by a single PHP file and Magento application is instantiated
- Application instantiate Front Controller Object
- Front Controller instantiate Routers
- Routers check URL and determines Controller and Actions
- Action Methods manipulate Models
- Action loads layout and kicks off rendering
- Templates, via Blocks, read from Models
- Blocks and Child Blocks render into HTML page
Note: Unlike other MVC patters, Magento Blocks refer to the Models for their data as Action Controller does not pass them data structure.