Home arrow PHP arrow Building an Error Logger with the Chain of Responsibility Pattern in PHP 5

Building an Error Logger with the Chain of Responsibility Pattern in PHP 5

If you’re one of those PHP developers that wants to expand your background in pattern-based programming, then this article may suit your needs. Welcome to the second part of the series “Understanding the Chain of Responsibility Between PHP Objects.” Comprised of three installments, this series goes through the basics of building a chain of responsibility across several PHP objects, and teaches you how to apply this pattern by using copious code samples.

TABLE OF CONTENTS:
  1. Building an Error Logger with the Chain of Responsibility Pattern in PHP 5
  2. Setting up the foundations of an error logger
  3. Logging specific errors at a lower level
  4. Logging email-related errors
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
November 06, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

As you'll remember, over the course of the first article I provided you with a friendly introduction to creating a well-defined chain of responsibility between certain PHP classes. It demonstrated how a given object can delegate the execution of a specific task to its parent when it can't handle the problem via its own methods.

Although this important concept was illustrated by using some basic classes that certainly can't be used in real conditions, hopefully the experience was good enough to teach you how the chain of responsibility model can be successfully implemented with PHP. Once the logic that stands behind this pattern is mastered, translating it to a more useful context is much simpler.

Keeping in mind the practical side of the subject, in this second tutorial of the series, I'll be covering the development of a custom error logging system, which also implements a chain of responsibility across its different classes to log errors to distinct modules.

In response to this experience, at the end of this article you should be equipped with more robust knowledge of how to create a responsibility chain between PHP objects that perform truly useful tasks, like logging errors to specific components of a Web application.

Having established the goal of this article, let's move forward and learn together how this pattern can be applied in a real world situation. Let's go!



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap

Dev Shed Tutorial Topics: