HomePHP More Examples of Creating Command Objects with PHP 5
More Examples of Creating Command Objects with PHP 5
Are you one of those PHP developers who wants to expand your background in design patterns by learning an additional one? If your answer is affirmative, then this series might be appealing to you. It will teach you, in three educational tutorials, how to create and implement command objects with PHP 5.
Frankly speaking, the application of the command pattern with PHP is an accessible topic that seems to be much harder to grasp than what it really is. Essentially, the logic that stands behind the referenced pattern will allow you to establish a carefully-crated relationship between at least two objects, where the first one, usually called the commanded, presents a specific method coded in such a way that it houses all the logic required for being called into another object, in this case named "commander."
Since the previous definition looks rather difficult to grasp, at least at first glance, the best course of action to take in this case is simply to annex to the corresponding theory into some comprehensive examples. In this way the mentioned pattern can be understood much more clearly, and at the same time, it brings new possibilities for including it into complex applications.
Naturally, in the previous article I followed the learning methodology that I mentioned above by defining some command classes, which were originally capable of instructing a commanded object on how to display a specified input string. Of course, the examples were rather primitive and they should be considered only like that. However, it's important to mention here that all the code samples that I wrote previously came in really handy for demonstrating by an understandable approach, how to create and use command objects with PHP.
Now, and turning special attention to this second article of the series, I'll develop a few more hands-on examples concerning the pattern in question, thus you can reaffirm the concepts learned in the preceding installment.
With the theme of this article already established, let's continue exploring the creation of command objects in PHP 5. Let's get started!