jnjxp/routeless

Aura\Router failed routing responder

0.1.0 2016-06-20 17:22 UTC

This package is auto-updated.

Last update: 2024-12-26 09:41:08 UTC


README

A failed routing responder for Aura\Router

Latest version Build Status Coverage Status Quality Score

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

See Handling Failure To Match

$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]);