The HMVC Design Pattern: Working with MySQL and Caching Data
(Page 1 of 4 )
If you’re a PHP coder who wants to expand your existing background in design patterns, then start reading this series of articles. Over the course of its tutorials, you’ll learn how to implement the Hierarchical Model-View-Controller paradigm by developing a fully-functional, object-oriented framework in PHP 5. This is the third part of the series.
And now that you're aware of the goal of this series, it's time to review the concepts discussed in the previous installment. In the second part of the series, I developed two core components of the aforementioned framework that will allow you to build PHP applications by using a basic HMVC layer.
The first of these components was composed of a router/dispatcher class that naturally was tasked with parsing a given HTTP request and dispatching it to the appropriate controller. Despite its simplicity and short definition, the second component was the most relevant; it consisted of a basic request-handling class that will permit you to map single requests to one or multiple Model-View-Controller triads, thus making it possible to run web-based programs by relying upon the architecture imposed by the HMVC pattern.
Although in its current incarnation the framework will let you build applications made up of individual MVC modules, it'd be desirable to make it much more functional by adding a few more classes that allow you to interact with MySQL and cache data. So, in the following lines I'm going to code those components, which you'll find very easy to follow, take my word for it.
Now, it's time to start providing this HMVC-based framework with the ability to work with MySQL databases and to cache data. Let's go!