HomePHP User-defined Interfaces in PHP 5: Building a Page Generator
User-defined Interfaces in PHP 5: Building a Page Generator
In this final part of the series on user-defined interfaces in PHP 5, Alejandro puts all of the classes created in the previous articles together to work as a page generator. This allows complex page generation to be translated into a more flexible process through an object-based solution.
Here we are again. Welcome to the last part of the series “User-defined interfaces in PHP5.” Although the subject is certainly thorough enough to be the topic of a complete book chapter, this series has hopefully served as an introduction to learning the basics of interfaces, as well as demonstrated how these programming structures can be used within real applications, such as those aimed at generating web pages by utilizing an object-oriented method.
By way of refreshing the concepts deployed in the previous article, I wrote two MySQL-processing classes that illustrated the use of the “HTMLRenderer” interface. They implemented the interface on result-type objects, and delivered fully-formatted result sets that could be easily integrated with minor difficulties into web page generation systems.
Of course the implementation of interfaces made through MySQL-processing classes along with (X)HTML widgets has clearly proven how objects of different family types can be easily grouped through the same set of abstract methods, which have a specific definition within each pertaining class.
Indeed, PHP5 provides web programmers with long awaited object-oriented features, such as support for interfaces, type hinting, abstract classes, and so forth, along with a powerful standard package (the Standard PHP Library), primarily intended to supply pre-built libraries for avoiding the so-called wheel reinvention.
With reference to this final part of the series, I shall put all of the classes to work together into a full-featured example, by including the already familiar (X)HTML widgets in conjunction with the pair of MySQL-processing classes, in order to integrate both types of objects into a page generator class. As a result, complex web page generation can be translated into a more flexible process tackled through an object-based solution. Let’s go!