This package provide trait and abstract class for your psr-15 middlewares to double pass middewares support. So you can call your middleware in both styles.
Standard PSR-15 call:
$middleware->process($request, $delegate);
Possible call after implements this package:
$middleware($request, $response, $next);
composer require php-middleware/double-pass-compatibility
You can add trait into your middeware:
class Middleware implements MiddlewareInterface
{
use PhpMiddleware\DoublePassCompatibilityTrait;
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
// Implementation and return response
}
}
Or extend abstract class:
class Middleware extend AbstractDoublePassCompatibilityMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
// Implementation and return response
}
}