Have Yourself a Model View Controller
Tags: php, webdev
Published: 2021-12-20 06:37:18

>**Just the Gist**  
>MVC is a popular design pattern that many PHP frameworks supports. Some of the most popular open-source MVC frameworks in the PHP world are Laravel, Symfony, and Yii.  

## A quick overview
A popular design pattern used in web development is the Model View Controller (MVC) pattern. MVC had its first implementation in a language called [*Smalltalk*](https://en.wikipedia.org/wiki/Smalltalk) in the late 70's. The aim was to put the user of a computer system in control of large and complex data sets. The short of the pattern is:  
* Model - representation of knowledge.
* View - a visual representation of the model.
* Controller - handling the user input and the model changes.

Many of us Web developers have been using MVC for years. And it has worked pretty well in most cases. Today we are listing some of the most popular frameworks in PHP that support MVC.  

## Some MVC frameworks to look for
This is not an exhaustive list of MVC frameworks, and we will return at a later time to look at some micro-frameworks. With that in mind, here's my list of the most popular MVC frameworks:

Framework | Github | ⭐ 
-- | -- | -- 
[**Laravel**](https://laravel.com/) | [laravel/laravel](https://github.com/laravel/laravel/) | 67.7k   
[**Symfony**](https://symfony.com/) | [symfony/symfony](https://github.com/symfony/symfony) | 26.2k 
[**Yii**](https://www.yiiframework.com/) | [yiisoft/yii2](https://github.com/yiisoft/yii2) | 13.9k 
[**CakePHP**](https://cakephp.org/) | [cakephp/cakephp](https://github.com/cakephp/cakephp) | 8.5k 
[**CodeIgniter**](https://codeigniter.com/) | [codeigniter4/CodeIgniter4](https://github.com/codeigniter4/CodeIgniter4) | 3.8k 

These are far from all of the available open-source PHP MVC frameworks. Here they are arranged in order of number of stars on GitHub - not the best metric of popularity. So let us hear what you are using and what you like.

### A personal take
I've come to really like Symfony. It may be because I was introduced to programming through Java and was first exposed to MVC frameworks with Spring Boot. That Symfony came packing with a dependency injection container felt just natural at the time. I've been using Symfony for most of my projects and I'm very happy with it. With this in mind, I have not ventured far beyond these pastures. I've *dabbled* with Laravel and was confused by its model-implementation. But I've also dabbled with Silverstripe and now the model-implementation is not as foreign to me any more. The reason that it felt foreign was that Symfony rather divided up a model into *entity* and *repository*. 

## What about you?
Please share your experience with the MVC frameworks you have been using. Are the popular frameworks suitable for what you are doing? Do they feel bloated or are they just about the right size? Which is your favorite framework? Maybe frameworks are not needed for your projects? Comment below and let us know what you think ✍

## Further Reading
* Trygve Reenskaug (10 December 1979) **Models - Views - Controllers** - https://folk.universitetetioslo.no/trygver/1979/mvc-2/1979-12-MVC.pdf