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

Named routes #11

Closed
tyler-sommer opened this issue Mar 4, 2014 · 4 comments
Closed

Named routes #11

tyler-sommer opened this issue Mar 4, 2014 · 4 comments

Comments

@tyler-sommer
Copy link
Contributor

Would it be worthwhile to extend the implementation to supports named routes? I don't think the routing algorithm cares about names, but it would be helpful for creating url generation helpers and the like.

Is FastRoute where that should be implemented, anyway?

@nikic
Copy link
Owner

nikic commented Mar 4, 2014

What's a named route?

@tyler-sommer
Copy link
Contributor Author

The name would be used to reference the route in the rest of the application.
My use case is something like this:

$collector->addNamedRoute('user_show', 'GET', '/user/{id}/show', 'showUser');

$urlGenerator = new UrlGenerator($collector->getNamedData());

$path = $urlGenerator->generate('user_show', ['id' => 5]);
// $path is "/user/5/show"

However, I don't know if this line of thinking necessarily fits with FastRoute. This could easily be added as a layer on top of FastRoute instead of being included.

@nikic
Copy link
Owner

nikic commented Mar 4, 2014

Yeah, I also think this would work well as a separate layer, as it's mainly about integration with the application.

@tyler-sommer
Copy link
Contributor Author

Awesome, thanks!

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