Home arrow PHP arrow An Introduction to Building Proxy Classes with PHP 5

An Introduction to Building Proxy Classes with PHP 5

If you create object-oriented programs in in PHP 5, you know that their performance can be improved by rationalizing the use of objects. The proxy pattern can help with this task. In this first of a two-part series, you will learn the key points of how to use this pattern with PHP 5.

TABLE OF CONTENTS:
  1. An Introduction to Building Proxy Classes with PHP 5
  2. Developing an expandable XML processor class
  3. Expanding the functionality of the ProxyXMLProcessor class
  4. Defining the XMLProcessor class
  5. Seeing the proxy class in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 9
January 02, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

During your life as PHP developer, quite possibly you'll have learned some useful approaches to improve the overall performance of object-based web applications. From using content/XHTML caching mechanisms and compressing web page outputs, to implementing a rational usage of the objects utilized by a given application, options are numerous. Logically, the best of this variety of possible improvements rests on the point that many of the methods I mentioned can be used in conjunction with applications that have been written using a procedural methodology.

Nevertheless, when it comes to working solely with object-oriented programs in PHP, it's possible to create applications that present a carefully-planned utilization of their different objects. One of the simplest approaches, implemented to avoid the duplication of costly objects, involves using the popular references in PHP 4 instead of working with multiples copies of the objects in question.

However, if you're looking for new techniques aimed at improving the performance of object-based PHP applications as a whole, I must say that there's more good news on the horizon: in the huge terrain of creational design patterns, there's one that can be used successfully for implementing a rational usage of objects. In this case, I'm referring specially to the proxy pattern, which offers many interesting features that can help to reduce significantly the overhead of an application.

But I'm sure you're wondering how this pattern works. Well, in short, in the proxy pattern, one object is created by another only when the functionality of the first one is required. This avoids unnecessary class instantiation. For this pattern in particular, the object called "proxy" is responsible for handling all the accesses to another class, something that looks very similar to the behavior of different proxy servers. Now, are you feeling more familiar with the functionality of this useful pattern? I'm sure you are.

Having introduced the basic definition of proxy objects in PHP, in this two-part series, I'm going to walk you through the key points of how to use this pattern with PHP 5, as well as how to apply it in different real-world situations.

With the preliminaries out of our way, let's start learning more about this handy design pattern. Let's go!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: