PHP
  Home arrow PHP arrow Page 3 - Introducing the Facade Pattern in PHP ...
Administration  
AJAX  
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 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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: 5 stars5 stars5 stars5 stars5 stars / 6
    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:
      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


    Introducing the Facade Pattern in PHP 5 - Using HTTP compression with PHP 5


    (Page 3 of 5 )

    In consonance with the concepts that I deployed in the section that you just read, the next step that I’m going to take will consist of defining a basic facade class. This class will be capable of applying HTTP compression to any input string, in addition to removing any eventual new line characters from it.

    Having outlined the functionality of this simple facade class, please pay attention to its definition. It’s as follows:

    // define 'CompressContentFacade' class
    class CompressContentFacade{
       public static function stripContent($content){
        
    // remove new lines from content
        
    $strippedContent=StripContent::stripString($content);
         // compress content by using GZIP algorithm
         $gzippedContent=GzipContent::compressString
    ($strippedContent);
         return $gzippedContent;
       }
    }

    Despite the remarkable simplicity of the above facade class, there are a few things worth stressing about its definition. First, notice how the class in question hides all the complexity required for removing new lines characters and compressing strings behind the interface of two different classes, “StripContent” and “GzipContent” respectively.

    Second, you should realize that all of these classes are completely independent from the facade one, which means that they know nothing about the class that called them. If you recall the definition of the facade pattern, this is exactly the schema required for applying it. Now, the prior facade class should make a lot of sense to you!

    Nevertheless, I must mention that the previous “CompressContentFacade” class is indeed only half of the story when it comes to implementing the facade pattern with PHP 5, since the corresponding string compressing classes that you saw before remain undefined.

    To address this issue, in the following section I’m going to show you the respective signature for these two new classes, in this way completing the model dictated by the facade pattern.

    Do you wish to see how these classes will be created? Jump ahead and read the next few lines.

    More PHP Articles
    More By Alejandro Gervasio


       · In this first part of the series, the foundations of the facade pattern are...
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT