Home arrow PHP arrow Introduction to Creating Command Objects with PHP 5

Introduction to Creating Command Objects with PHP 5

In this article, the first part of a series, you'll learn the basics of applying the command pattern with PHP 5. As always, plenty of hands-on examples are included.

TABLE OF CONTENTS:
  1. Introduction to Creating Command Objects with PHP 5
  2. Creating a command class
  3. Creating additional command classes
  4. Defining a commanded class
  5. Putting all the classes to work together
By: Alejandro Gervasio
Rating: starstarstarstarstar / 14
December 12, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

If you've achieved a considerable background working with PHP, then you'll agree with me that one of the most exciting aspects of using this server-side scripting language is experimenting with the neat capabilities offered by its Object Model (this is true, particularly with PHP 5). Numerous and useful features have been added to original package to provide developers with more robust and reliable object-based programming tools for developing web applications.

However, the more you explore the advanced capabilities of PHP, the more you want to know about translating to functional code all the theoretical concepts that you learned in your career. Of course, this situation is also applicable to implementing several design patterns, since many of them are rather hard to grasp, at least if you don't have the chance to see these patterns applied in a concrete case where you can understand more easily how they work.

Driven by the simple motivation of giving you a few useful pointers on how to apply some specific design patterns that may potentially be interesting to you, in this three-part series, I'll introduce the use of command objects in PHP 5, or what's known popularly as the command pattern. But before I proceed to show you some concrete code related to the referenced topic, first let me tell you how this pattern works. In the command pattern, one object encloses all the programming logic required for executing a specific method into another one. Sounds pretty simple, doesn't it?

In this case, the object responsible for encapsulating the logic of a method into another is called the commanded one, while the object that calls the method in question is the commander. Most of the time, the commander exposes an "execute()" method or something similar, which is only responsible for invoking a method of the mentioned commanded. Naturally, this group of buzzwords that I have used will be much easier to grasp when you take a look at the introductory examples that you'll learn over the course of this series.

Okay, at this stage hopefully the creation and implementation of the command pattern with PHP 5 has already caught your attention, so let's move on together and start learning more on how this pattern can be applied with a few comprehensible hands-on examples. Let's go!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: