ideationnet/router-middleware

This package is abandoned and no longer maintained. The author suggests using the ideationnet/invoker-router-middleware package instead.

PSR-15 compatible invoker router middleware

dev-master / 1.0.x-dev 2016-11-29 12:16 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:03:23 UTC


README

A simple PSR-15 compatible router middleware, based on Fast Route.

Install

Via Composer

$ composer require ideationnet/router-middleware

Usage

Use with your favourite PSR-15 middleware dispatcher, like Stack Runner. Inject an instance of FastRoute\Dispatcher. Two different dispatchers? Is that confusing enough? One of them processes the stack of middleware, the other (probably at the bottom of this stack) will route to the correct controller. See Wafer for an example of this used with PHP-DI...

return [

    'routes' => [],
    
    Dispatcher::class => function (ContainerInterface $c) {
        return simpleDispatcher(function (RouteCollector $r) use ($c) {
            array_map(function ($route) use ($r) {
                call_user_func_array([$r, 'addRoute'], $route);
            }, $c->get('routes'));
        });
    },
    
];

Security

If you discover any security related issues, please email darren@darrenmothersele.com instead of using the issue tracker.

Credits

License

The MIT License. Please see License File for more information.