-
Notifications
You must be signed in to change notification settings - Fork 0
Named Routes
Joshua Parker edited this page Aug 22, 2020
·
1 revision
Routes can be named so that their URL can be generated programatically:
$router->map(['GET'], 'post/all', function () {})->name('posts.index');
$url = $router->url('posts.index');
If the route requires parameters, you can pass an associative array as a second parameter:
$router->map(['GET'], 'post/{id}', function () {})->name('posts.show');
$url = $router->url('posts.show', ['id' => 123]);
If a parameter fails the regex constraint applied, a RouteParamFailedConstraintException
will be thrown.