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

Nested groups are required #323

Closed kimjohans closed 2 years ago

kimjohans commented 2 years ago

I found your closed issue https://github.com/thephpleague/route/issues/96

We think about using your plugin in our very complex app. But we (urgently) require nested routing groups, because it is not optimal to use multiple singe group definitions:

$router->group("/user", function($router) {
  $router->map("GET", "/", ...
  $router->map("GET", "/list", ...
  $router->group("/modify", ..
    $router->map("GET", "/name", ....
    $router->("/details", ...
      $router->map("GET", "/usercode", ....
});

You understand the scheme ? When we should define all groups in single blocks:

$router->group("/user", function($router) {
  $router->map("GET", "/", ...
  $router->map("GET", "/list", ...
})

$router->group("user/modify", ..
    $router->map("GET", "/name", ....
})

$router->("user/modify/details", ...
  $router->map("GET", "/usercode", ....
});

If you have to change the path "user/" not ... that will easily end up in a complete mess ! With "search and replace" the keyword "/user" ... it will also replace mapped functions.

Most framework offer this methods (of course), because they are (in our opinion) a basic method of organizing and structuring routing and workflows.

Is there a change to get this feature or will this ticket (like #96) also be closed ? If so, pls give me some feedback and we'll have to change the routing package. Thank you.

philipobenito commented 2 years ago

It's unlikely that this will be introduced, iirc, when I considered it before, I didn't like the trade off from whatever solutions I was looking at, reusing a route group within a group opened up huge potential for user land error, and have multiple levels of groups introduced more complexity than I was comfortable with.

Happy to look at a PR if you can find a nice solution but it would need heavy scrutiny.