Coding Controllers and Views for the HMVC Design Pattern
(Page 1 of 4 )
In this eighth part of a nine-part series on the hierarchical model-view-controller design pattern, I added to our sample web application a couple of MVC modules that will be used for building the link bar and the main section of a web page.
As with many other design patterns used commonly in software programming (and more specifically in web development), learning the foundations of the Hierarchical Model-View-Controller paradigm in PHP 5 is a process that must be tackled by using a balanced combination of theoretical concepts and strong practice, applied in that specific order.
While the first requirement is pretty easy to suit, as the web boasts plenty of tutorials, articles and references that together provide a thorough guide to the inner workings of this architectural pattern, the second part is, for obvious reasons, much harder to accomplish. Many tutorials do offer a good introduction to using the HMVC approach, but very often they run out of examples when it's time to show how to use the pattern within the context of a real-world application.
In an attempt to cover the implementation of this pattern from a hands-on point of view, this group of articles will teach you how to build an extensible PHP 5 framework, whose building blocks can be easily put to work together under a fully-functional HMVC layer.
Naturally, if you've already read all of the tutorials that precede this one, then you have a pretty clear idea of how to use the aforementioned framework for developing applications that follow the schema dictated by the HMVC design pattern. In those installments of this series I developed a stack of reusable classes that permit you to build programs that support a typical MVC cycle and a hierarchical version of it as well.
Speaking more specifically, I left off the last part of the series developing a sample application whose main goal was to render a simple web page by fetching data from two different MySQL tables. Regardless of how trivial this example may look at first sight, itíll come in handy for demonstrating how to construct different sections of an HTML page using two independent MVC triads.
At this point, the sample application is composed of the corresponding MySQL tables and the model classes that handle the data that they store. So, the next step we must take is to create the controllers and views that will make up the pertinent MVC triads. Thatís exactly what Iím going to do in the next few lines. So click on the link below and start reading right now!