DEV Community

loading...
Cover image for Why you should create your own PHP MVC Framework

Why you should create your own PHP MVC Framework

achourmeguenni profile image Achour Meguenni ・2 min read

So its very clear that using a framework to build up your website is an important thing, you can save a lot of time and energy by using one like Laravel or code igniter 3, but there's one thing that web developers beginners should understand and its the MVC architecture and how does it work, and in order to understand it you should build your own MVC framework, so when you use another advanced framework you know what you are doing and you know the role of the controller, the model and the view and why they exist, sure you can read about that but there's nothing better than learning by practice, back to 2015 when I first created my first own MVC framework, I gain a lot of experience and my php skills dramatically improved.

The reason beginners get stuck to understand frameworks and take a long time to learn the basics is that they don't really understand the MVC architecture, once you get used with it, everything becomes easy.

Here are the things I learnt by that:

I learnt how to create a validation system.
How does routing work.
I knew about .htaccess.
I learnt how to use PDO.
I built a query builder which made my code very organized and easy to read.
I created a views system with basic PHP and HTML templating.
I learnt about flashing error messages using session.

So now when ever I use a framework I know what I'm doing when writing code, and in final its a was great learning curve, I advice every beginner to take the experience and put some efforts to do so, YouTube is full of courses you just need determination.

https://www.buymeacoffee.com/achour

Discussion (1)

pic
Editor guide
Collapse
kevinhickssw profile image
Kevin Hicks

Another great way to learn what goes into an MVC framework and how things work is to try rebuilding parts of an existing framework. This will both help learn how the framework you want to use works while guiding you through how to create your own. When you get stuck on your own framework or want to see how they did something you really like you can jump into the framework's source code to see how it works.

One huge thing I would recommend, especially for beginners, is to not use your own framework for a production site that is important. The pre-built frameworks handle a lot of security concerns most beginners aren't going to be familiar with and may not be able to keep up with the latest threats at the speed a mature framework can.