PHP
  Home arrow PHP arrow Introducing the Facade Pattern in 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? 
PHP

Introducing the Facade Pattern in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2007-01-16


    Table of Contents:
  • Introducing the Facade Pattern in PHP 5
  • A basic implementation of the facade pattern
  • Using HTTP compression with PHP 5
  • Completing the facade schema
  • Seeing the facade pattern in action

  • 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


    Introducing the Facade Pattern in PHP 5
    ( Page 1 of 5 )

    The facade pattern may be one of the less well known patterns in PHP, but it definitely has its uses. In this first article of a two-part series, you'll learn the basics of how the facade pattern works, illustrated with numerous examples.

    As you’ll certainly agree, pattern-based PHP programming is sometimes a hard-to-master topic. It logically has to be addressed with a considerable level of knowledge (and experience, to be frank), more specifically in those cases where the design pattern to be implemented presents a high grade of abstraction.

    Of course, this doesn’t mean that all of the PHP applications that you’re going to develop from this point onward must solve programming-related problems by utilizing a particular pattern. However, learning how to apply different design patterns to tackle common and well-known issues may help to expand your existing background as PHP developer, in addition to improving your overall experience.

    Assuming that the previous paragraphs already convinced you that learning pattern-based programming with PHP might be an instructive and educational experience, in this series, which is comprised of two comprehensive articles, I’m going to introduce the foundations of an interesting structural pattern. I’m talking specifically of the facade pattern.

    Since I have to admit that this one isn’t very commonly used amid the huge terrain of PHP-based web development, let me first walk you through a brief introduction about what it does. In this way you can anticipate what you’ll learn in the course of these two articles.

    To put it simply, the facade pattern can be applied in those situations where you need to create a PHP class which requires the implementation of a complex system as part of one of its methods. At first glance, the previous definition sounds like something applicable in many cases, but the advantage of using a facade schema relies on the point that the class can hide all the logic of the mentioned mechanism, while the mechanism in question knows nothing about the calling class. That sounds pretty good, right?

    To clarify the above concepts a bit more, allow me to cite an illustrative example: suppose you have a class which uses a complex set of additional classes to serialize/unserialize different objects before saving them to a database table. In this case, you have a class that hides all the complexity required for serializing the mentioned objects, but there’s also a group of classes that know nothing about the class that called them. As you can see, these classes are only responsible for performing the serialization/unserialization sequence on several objects and nothing else. Period.

    Now, are you’re starting to grasp the logic behind the facade pattern? Of course you are!

    At this moment , and after explaining a few basic points on how to use the facade pattern with PHP, let’s move forward and learn how all these theoretical concepts can be translated into some functional hands-on examples. Are you ready? Good, let’s get started!



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

       

    PHP ARTICLES

    - 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
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT