Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for route groups, namespaces and constraints #156

Open
koenpunt opened this issue Jun 21, 2016 · 1 comment
Open

Support for route groups, namespaces and constraints #156

koenpunt opened this issue Jun 21, 2016 · 1 comment

Comments

@koenpunt
Copy link
Collaborator

koenpunt commented Jun 21, 2016

Because there have been multiple issues and/or pull requests about route groups, namespaces and constraints, here a central issue to the discuss the requirements for such a feature.

I think nested function would be a nice way to group routes.

For example:

$router->group(array('path' => '/prefix'), function($router) {
  #=> matches /prefix/index
  $router->map('GET', '/index', 'some_action');

  $router->group(array('path' => '/admin'), function($router) {
    #=> matches /prefix/admin/index
    $router->map('GET', '/index', 'some_action');
  });
});

Or more generic with some sort of middleware:

$router->group(function($method, $route, $target, $name = null) {
  // this method is called for all routes in a group
  return [$method, '/admin' . $route, $target, $name];
}, function($router) {
  #=> matches /admin/index
  $router->map('GET', '/index', 'some_action');
});

But more suggestions are welcome.


cc: #52 #83 #149

@dannyvankooten
Copy link
Owner

dannyvankooten commented Jun 22, 2016

I think it would be cool to add support for this, but not super sold on it yet as it's also a fairly trivial thing to do yourself (as you did already, I believe).

What other group types will we allow besides path prefixes. Subdomain? HTTP methods? If we're just supporting path prefixes, do we need the configuration array at all?

From first sight, I do prefer the first proposed syntax over the second one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants