thewebsolver / pipeline
Follows Chain of Responsibility Design Pattern to handle the given subject/request.
Requires
- php: >=8.2.0
- psr/container: ^2.0
Requires (Dev)
- phpunit/phpunit: 9.6.10
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
README
TheWebSolver Pipeline library follows the 🔗 Chain of Responsibility Design Pattern 🔗 to handle the given subject/request using pipes. The pipeline can accept any subject type, passes it through provided pipes and return the updated subject back.
Installation (via Composer)
Install library using composer command:
$ composer require thewebsolver/pipeline
Benefits
-
Follows Chain of Responsibility design pattern by passing subject to pipeline handlers in order they were stacked.
Use
Pipeline::through()
method to pass main handlers as pipe. Optionally, pass additional handlers usingPipeline::pipe()
method. -
Provides support for additional arguments that can be accepted by each handler passed using above methods.
Use
Pipeline::use()
method to pass as many arguments as required. -
Provides support for catching Pipe Exception or Unexpected Exception thrown by the handler.
Use
Pipeline::sealWith()
method to pass a closure to handle thrown exception. -
Provides bridge for PHP Projects that implements PSR-7, PSR-15 (optional PSR-11) standards.
Use Queue based Request Handler implementation to handle stacked middlewares inside Request Handler's handle method (
RequestHandlerInterface::handle()
).
Usage
For usage details, visit Wiki page.