thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Named route in nested route group does not exists #254

Closed odan closed 5 years ago

odan commented 5 years ago

If I add a route within a route group, the route cannot be resolved by name.

Example

use League\Route\RouteGroup;
use League\Route\Router;

$router = new League\Route\Router();

$router->group('', function (RouteGroup $group): void {
    $group->get('/', \App\Action\HomeIndexAction::class)->setName('root');
});

// A quick test
$router->getNamedRoute('root');

Error message: No route of the name (root) exists

This is just a minimal example. In reality I have much more named routes. The problem is, they cannot be found if the name is defined in a route group.