HomePHP Adding a Controller Class to an MVC-Based Framework in PHP 5
Adding a Controller Class to an MVC-Based Framework in PHP 5
In this tenth part of the series, I start building a basic MySQL-driven application whose main tasks consist of selecting, inserting, updating and deleting records on some hypothetical users by means of the framework we've built.
As you know, in the last few years the proliferation of PHP frameworks on the web has been so rapid and vast that now a PHP developer has a plethora of options to choose from.
While some frameworks that are more popular than others, all of them try to make PHP programmers' lives much easier by providing them with a set of reusable components that can vastly speed up the development of modern web applications.
With the variety of frameworks available nowadays, you've probably already started using one that implements the Model-View-Controller design pattern, such as Zend, Kohana or CodeIgniter, to name just a few. However, it's possible that you may want to build your own MVC-driven framework, or acquire a more solid understanding of how the existing ones function internally.
If that's the case, then in this group of tutorials you'll find a guide that will show you in a step-by-step fashion how to build a simple framework in PHP 5 that will stick to the architecture imposed by the Model-View-Controller design pattern.
And now that you've been introduced to the subject of this article series, it's time to review the topics covered in the last part. In that part of the series I added another core component to the framework being developed -- a model class whose main task was handling, via a simple API, the framework's data layer, composed of one or more MySQL tables.
True to form, the stack of libraries created so far allow you to implement the "M" and "V" sections of the MVC pattern, which are the Model and View layers respectively. So, what's the missing part of this schema? Yes, you guessed right! It's necessary to build a controller class that glues these two pieces together.
Thus, in the lines to come I'm going to start building a basic MySQL-driven application that will use not only a controller class, but all of the framework's previously-created components. Let's begin.