Download the PHP package echo-fusion/middlewaremanager without Composer
On this page you can find all versions of the php package echo-fusion/middlewaremanager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download echo-fusion/middlewaremanager
More information about echo-fusion/middlewaremanager
Files in echo-fusion/middlewaremanager
Package middlewaremanager
Short Description a middleware manager implements PSR-15 and PSR-7
License MIT
Informations about the package middlewaremanager
MiddlewareManager
This is a flexible package for managing middleware in PHP applications. It enables you to create a middleware pipeline, where middleware processes a request and passes it on to the next, providing a clean and organized way to handle middleware logic.
This package is compliant with PSR-1, PSR-2, PSR-7 and PSR-15.
Installation
Install the package via Composer:
Requirements
The following versions of PHP are supported by this version.
- PHP 8.1
- PHP 8.2
- PHP 8.3
Usage
Here’s how to use the MiddlewareManager to set up and run a middleware pipeline.
1. Define handler
Define your handlers in proper directory and pass one of them to middleware manager to run it at the end of the pipeline:
2. Define middlewares
Define your middlewares in proper directory in separate files:
3. Run MiddlewareManager
To add middleware to the manager, you have two options:
- Add middleware as 'core middleware', which always runs before any middleware added later.
- Add middleware dynamically (e.g., useful for adding route-specific middleware).
Here is an example of how you can run MiddlewareManager:
Note: Don't forget to instantiate below injected dependencies in your container.
Testing
Testing includes PHPUnit and PHPStan (Level 7).
Credits
Developed and maintained by Amir Shadanfar.
Connect on LinkedIn.
License
The MIT License (MIT). Please see License File for more information.
All versions of middlewaremanager with dependencies
psr/container Version ^2.0
psr/http-message Version ^2.0
guzzlehttp/psr7 Version ^2.5
psr/http-server-middleware Version ^1.0@dev