PHP
  Home arrow PHP arrow Introduction to Creating Command Objects with PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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? 
Google.com  
PHP

Introduction to Creating Command Objects with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek