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!
blog comments powered by Disqus |