CodeIgniter 4 MVC ArchitectureMr.Go
When we are learning any framework, it’s very important to know about MVC architecure. If we can understand MVC flow, we can easily learn framework. All the frameworks which are created in PHP are based on MVC only. So that if you know one framework then others will be very easy to learn.
What is an MVC ?
MVC is design pattern, A design pattern will always suggests how to organize our code. The main goal of MVC architecure is to separate the Presentation logic with Business logic.
What is Presentation Logic: The Presentation logic will always deals with front end designs like HTML, CSS and more.
What is Business Logic: The Business logic will always deals with database operation like insert, delete, select, update and more…
MVC stands for Model View Controller
What is a Model?
Models are nothing but PHP class files which stored in Models Folders. Models are always deals with Database operations like select,insert,delete,update etc…
What is a view?
Views are nothing but HTML templates stored in Views folder. Views are always deals with front end nothing but HTML,CSS,..
What is a Controller?
The HEART of MVC architecture is a Controller, also called as TRAFFIC COP. How a traffic cop will controls the traffic in the same manner, The Controller will also controls requests and responses which are coming to our application.
- When a request coming to our application from browser, At first the request was received by a Controller only
- In MVC, No one will access a view or model directly.
- If we want to access a Model or a view, That should happens via a controller only.
- In MVC, a model and a view will never communicate directly