Model, View, Controller – MVC
When working with modern object-oriented programming (OOP) frameworks in PHP, such as Symfony or Laravel, the first pattern you are going to see is called MVC – Model, View, Controller (https://w.wiki/znd).
In MVC, your application is split into three main areas. I think you can guess what the names are!
These three areas are as follows:
- Model: The data for your application – including CRUD (create, retrieve, update, delete).
- View: The visual – taking data and creating the output (usually HTML for PHP developers).
- Controller: The bit that handles requests. It uses the model to process data and prepare it for the View, then passes it to the View for rendering before finally serving back up as a response.
To assist with understanding MVC, I've put together a very simple "toy" MVC application. It is deliberately simple and lacks many features provided by full-blown frameworks, but I hope...