PSR-15's middleware pattern can be applied beyond HTTP to any PHP library component as a more flexible alternative to the Decorator pattern. The approach involves creating a middleware interface that mirrors the component interface with an added `$next` parameter, a delegator class to bridge the two, and using `array_reduce` to
Table of contents
What PSR-15 Got Right #The Problem with Decorators #Applying the Pattern to Any Component #Two Concrete Middlewares #Before, After, and Both #Wiring It Together #What This Gives Your Users #Sort: