fratily/router

Installs: 149

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/fratily/router

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

This package is auto-updated.

Last update: 2025-09-23 23:52:47 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');