A pipeline implementation for square one

4.2.0 2022-10-25 16:44 UTC


This is a customized implementation of Laravel's illuminate/pipeline to work with PHP-DI and to allow passing additional parameters to your stages.

This library implements a version of the Collection Pipeline Design Pattern and the Chain of Responsibility Design Pattern.

This system is what powers Laravel's Middleware under the hood and is very useful if you want to run multiple operations in a sequence on the same data set.

Each stage can perform a specific operation, or decide to skip that operation based on some condition and pass the data to the next stage in line.

See the integration tests for some basic example use cases.

Example Use Cases

  1. As request/response middleware or any middleware.
  2. As a filter/facet system, e.g. building a query based on a number of selectable parameters: sort/order, post status, date etc...
  3. As an access control system, allowing access by role or a number of different conditions.
  4. As a formatting/transforming/data mapping system.
  5. As a sanitizing system, performing different sanitization techniques based on the structure of the data.