As I said before, below I developed a comprehensive example that demonstrates how the facade pattern can be used for compressing the HTTP output of a specific web page, in this case by using all the classes that were created previously. Please take a look at the following code sample: // example using 'CompressContentFacade' class In the above example, you can see that I first instantiated a new “WebPage” object, then generated the different sections that comprise a sample web document, and finally used the “CompressContentFacade” class to compress the respective HTTP output before sending it straight to the browser. Do you see how applying the facade pattern with PHP 5 was much simpler that you might have thought? I bet you do! Final thoughts Finally, we’ve come to the end of this tutorial. In this first part of the series, I introduced the key points for how to implement the facade pattern with PHP 5 with some illustrative examples. However, this isn’t the end of this educational journey. In the last installment, I’ll teach you how to use a facade class in conjunction with a file processing application. You won’t want to miss it!
blog comments powered by Disqus |