Skip to content

Commit

Permalink
Added a docs note about the reverse routing info.
Browse files Browse the repository at this point in the history
Ref #287
  • Loading branch information
Fredrik Sundblom committed May 20, 2021
1 parent 5a343e9 commit dee2d41
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/5.x/routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ GET /admin/acme/route2
GET /admin/acme/route3
~~~

### Named Routes

Named routes helps when you want to retrieve a Route by a human friendly label.

~~~php
<?php declare(strict_types=1);

$router = new League\Route\Router;
$request = new Request; // Psr/Http/Message/ServerRequestInterface

$router->group('/admin', function (\League\Route\RouteGroup $route) {
$route->map('GET', '/acme/route1', 'AcmeController::actionOne')->setName('actionOne');
$route->map('GET', '/acme/route2', 'AcmeController::actionTwo')->setName('actionTwo');
});

$route = $router->getNamedRoute('actionOne');
$route->getPath(); // "/admin/acme/route1"
~~~

### Conditions

As mentioned above, route conditions can be applied to a group and will be matched across all routes contained in that group, specific routes within the group can override this functionality as displayed below.
Expand Down

0 comments on commit dee2d41

Please sign in to comment.