PHP
  Home arrow PHP arrow Introduction to Creating Command Objec...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
eWeek
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Introduction to Creating Command Objects with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2006-12-12

    Table of Contents:
  • Introduction to Creating Command Objects with PHP 5
  • Creating a command class
  • Creating additional command classes
  • Defining a commanded class
  • Putting all the classes to work together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Introduction to Creating Command Objects with PHP 5
    (Page 1 of 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.

    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


       · In this first article of the series, you'll learn the key points of applying the...
       · This is a good example of the Command pattern in PHP, i'm not sure why you've moved...
       · Hi James,Thank you for commenting on my PHP article. With reference to your...
     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway