jnjxp / routeless
Aura\Router failed routing responder
0.1.0
2016-06-20 17:22 UTC
Requires
- aura/router: ^3.0
- psr/http-message: ^1.0
Requires (Dev)
- radar/adr: ~1.0
- zendframework/zend-diactoros: ~1.0
This package is auto-updated.
Last update: 2024-10-26 09:17:07 UTC
README
A failed routing responder for Aura\Router
Installation
composer require jnjxp/routeless
Usage
See Aura\Router documentation.
Instantiation
use Jnjxp\Routeless\RoutingiFailedResponder; $factories = [ MyCustomRule::class => function () { return new My\Custom\Rule\Responder(); } ]; $failResponder = new RoutingFailedResponder($factories);
Responder Signature
function __invoke(Request $request, Response $response, Route $route);
Aura\Router
$route = $matcher->match($request); if (! $route) { $failedRoute = $matcher->getFailedRoute(); $response = $failedResponder($request, $response, $failedRoute): }
Radar\Adr
See: Radar.Project > Container Configuration > Configuration (aka "Providers") .
use Radar\Adr\Boot; use Jnjxp\Routeless\Config as RoutlessConfig; $boot = new Boot(); $adr = $boot->adr([RoutelessConfig::class]); // or $routelessConfig = new RoutelessConfig( [ MyCustomRule::class => MyCustomResponse::class, MyOtherRule::class => MyOtherResponse::class, ] ); $adr = $boot->adr([$routlessConfig]);