Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Introduction to Chain of Responsibility
Jun 24, 2015 @ 15:26:17

The SitePoint PHP blog has a recent post where they dig into the details of the Chain of Responsibility design pattern, a commonly used structure that makes for easier workflow handling and encapsulation.

The Chain of Responsibility is a behavioral design pattern that processes a request through a series of processor (handlers/receivers) objects. The request is sent from one handler object to another and processed by one (pure implementation) or all of the handlers. All the handlers are part of the chain.

They get into the detail of the parts of the pattern first: the abstract handler that defines the structure and a set of concrete handler classes based on this structure. He also mentions a few other object types that could be involved including a Client, Request and Response objects. He includes an example of the base abstract handler class with "setSuccessor" and "handler" methods to provide the "chain" from one handler to another. He creates a more advanced version of the handler that does some additional checking on the handler results to see if it needs to continue. Finally, he gets down to the Client class that handles the ordering of the chain before processing. He also shows how a service container (dependency injection) could be integrated to manage creating object instances.

tagged: chainofresponsibility designpattern tutorial order workflow

Link: http://www.sitepoint.com/introduction-to-chain-of-responsibility/

Anthony Ferrara's Blog:
Handling Plugins In PHP
Mar 09, 2012 @ 19:34:38

Anthony Ferrara has a new post today looking at plugin handling and a few of the more common design patterns that can be used to implement them in your applications.

A common problem that developers face when building applications is how to allow the application to be "plug-able" at runtime. Meaning, to allow non-core code to modify the way an application is processed at runtime. There are a lot of different ways that this can be done, and lots of examples of it in real life. Over a year ago, I wrote a StackOverflow Answer on this topic. However, I think it deserves another look. So let's look at some patterns and common implementations.

The patterns he covers are:

  • Observer
  • Mediator
  • Strategy
  • Decorator
  • Chain of Responsibility

For each there's both a bit of sample code showing it in use and links to some examples from various frameworks and other projects.

tagged: plugin designpattern observer mediator strategy decorator chainofresponsibility

Link:

DevShed:
Expanding an Error Logger with the Chain of Responsibility Pattern
Nov 13, 2006 @ 16:57:00

Finishing off their look at the "chain of responsibility", DevShed has posted part three of the series - expanding on the code that they produced in the past, they add more functionality to their error logger.

Now, paying attention to the topics that will be covered in this tutorial, what you'll learn here will consist essentially of applying the chain of responsibility schema to expand the capacity of the error logging system that was developed previously.

They take a look back at what they produced in the previous tutorial (the simple error logger) and show how to expand on it by adding functionality to log errors to a file. The finish it off by showing how to implement it all in a simple script.

tagged: error logger chainofresponsibility pattern expand error logger chainofresponsibility pattern expand

Link:

DevShed:
Expanding an Error Logger with the Chain of Responsibility Pattern
Nov 13, 2006 @ 16:57:00

Finishing off their look at the "chain of responsibility", DevShed has posted part three of the series - expanding on the code that they produced in the past, they add more functionality to their error logger.

Now, paying attention to the topics that will be covered in this tutorial, what you'll learn here will consist essentially of applying the chain of responsibility schema to expand the capacity of the error logging system that was developed previously.

They take a look back at what they produced in the previous tutorial (the simple error logger) and show how to expand on it by adding functionality to log errors to a file. The finish it off by showing how to implement it all in a simple script.

tagged: error logger chainofresponsibility pattern expand error logger chainofresponsibility pattern expand

Link:

DevShed:
Building an Error Logger with the Chain of Responsibility Pattern in PHP 5
Nov 06, 2006 @ 16:32:00

With the next link in their look at the "chain of responsibility" pattern, DevShed has posted this new part in the series - adding an error logger to the mix.

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.

They work from the code built up in the previous installations and show how to add the foundations of the error logger to the class before moving on to the more advanced bits. They then show how to use it to log some basic errors and, using only a bit more skill, logging some email-related errors.

tagged: error logger chainofresponsibility pattern php5 tutorial error logger chainofresponsibility pattern php5 tutorial

Link:

DevShed:
Building an Error Logger with the Chain of Responsibility Pattern in PHP 5
Nov 06, 2006 @ 16:32:00

With the next link in their look at the "chain of responsibility" pattern, DevShed has posted this new part in the series - adding an error logger to the mix.

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.

They work from the code built up in the previous installations and show how to add the foundations of the error logger to the class before moving on to the more advanced bits. They then show how to use it to log some basic errors and, using only a bit more skill, logging some email-related errors.

tagged: error logger chainofresponsibility pattern php5 tutorial error logger chainofresponsibility pattern php5 tutorial

Link:


Trending Topics: