Skip to content

PSR-15 compliant middleware dispatcher for PHP 7

License

Notifications You must be signed in to change notification settings

acelot/middleware-dispatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Middleware Dispatcher

packagist deps license

PSR-15 compliant middleware dispatcher.

Install

composer require acelot/middleware-dispatcher

Also you need to install some PSR-11 compliant DI container like acelot/resolver or php-di/php-di.

Example

entrypoint.php

$resolver = new Psr11CompliantDiContainer();

$dispatcher = new MiddlewareDispatcher($resolver, [
    FirstMiddleware::class,
    SecondMiddleware::class,
    ThirdMiddleware::class,
    ...,
    LastMiddleware::class
]);

$response = $dispatcher->handle($serverRequest);

FirstMiddleware.php

class FirstMiddleware implements MiddlewareInterface
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Request handler
    }
}

About

PSR-15 compliant middleware dispatcher for PHP 7

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages