🎉 Hooray! After 3 years of work, I've finally released the ebook on design patterns! Check it out »
Chain of Responsibility

Chain of Responsibility in PHP

Chain of Responsibility is behavioral design pattern that allows passing request along the chain of potential handlers until one of them handles request.

The pattern allows multiple objects to handle the request without coupling sender class to the concrete classes of the receivers. The chain can be composed dynamically at runtime with any handler that follows a standard handler interface.

Learn more about Chain of Responsibility

Usage of the pattern in PHP

Complexity:

Popularity:

Usage examples: The Chain of Responsibility pattern isn’t very common in PHP, since it requires the program to have chains of objects. Arguably, one of the most famous examples of using this pattern in PHP is HTTP Request Middleware described in PSR-15.

Chain of Responsibility in Other Languages

Chain of Responsibility in Java Chain of Responsibility in C# Chain of Responsibility in Python Chain of Responsibility in Ruby Chain of Responsibility in Swift Chain of Responsibility in TypeScript