HomePHP Creating a Blog Application with Interpreter Classes with PHP 5
Creating a Blog Application with Interpreter Classes with PHP 5
Working with interpreter classes in PHP 5 can be a useful experience for any PHP developer. Welcome to the final part of the series that began with “Building Interpreter Classes with PHP 5.” Composed of three educational tutorials, this series teaches you how to implement the interpreter pattern with PHP, by covering not only the corresponding theoretical concepts, but also showing you concrete cases where this pattern can be applied in a useful way.
If you read the two previous articles of the series and examined the numerous code samples shown in these tutorials, it's quite probable that building interpreter classes with PHP 5 is now a familiar process to you, which can be tackled effortlessly. Nonetheless, if this pattern doesn't ring any bells to you, let me give you a quick introduction to how it works. In doing so, I certainly believe that you'll be much better equipped to grasp the logic of the hands-on example that I plan to develop in this final part of the series.
In plain terms, when the interpreter pattern is implemented, on one hand there's a class, obviously called "interpreter," which is tasked with parsing a set of predefined commands to perform a number of specific tasks. On the other hand there's one or more additional classes, which are responsible for sending those commands to the interpreter, in this way establishing a well-defined relationship between all these classes.
Of course, after rereading the previous definition, you might think that an interpreter class is some kind of basic parser. That's completely correct. As you can see, the logic that drives the interpreter pattern is rather easy to understand and implement with functional PHP code. Therefore, in this final installment of the series, I'm going to demonstrate how to get the most out of this handy pattern by developing a highly expansible blogging application. The application will be able to insert, update and delete blog entries, using a simple MySQL database as backend.
Having established the topics that will be covered in the next few lines, let's move on and learn together how to apply the interpreter pattern to build a simple blogging system. Let's begin now!