fratily/router

v2.0.0 2022-03-23 15:02 UTC

This package is auto-updated.

Last update: 2024-04-23 20:39:26 UTC


README

Usage

use Fratily\Router\RouterBuilder;
use Fratily\Router\Route;
use Fratily\Router\RouteOption;

$option = new RouteOption();
$routes = [
    new Route('/', $option->strictCheckTrailing(false)),
    new Route('/foo/bar', $option->strictCheckTrailing(false)),
    new Route('/foo/:name'),
    $matchRoute = (new Route('/foo/:name/setting')),
    new Route('/foo/:name/profile'),
    new Route('/bar'),
    new Route('/baz'),
];

$router = (new RouterBuilder($routes))->build();

[
    'route' => $route, // $matchRoute
    'params' => $params // ['name' => 'any']
] = $router->match('/foo/any/setting');