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

Feature: reverse URL creation #8

Open
mindplay-dk opened this issue Aug 7, 2017 · 0 comments
Open

Feature: reverse URL creation #8

mindplay-dk opened this issue Aug 7, 2017 · 0 comments

Comments

@mindplay-dk
Copy link
Owner

Add support for reverse URL creation, e.g. for the following route:

$router->route('users/<username:slug>')->get(ShowUser::class);

This feature would enable URL creation based on the defined route template, e.g.:

$user_url = $url_helper->createURL(ShowUser::class, ["username" => $username]);

Where the Router currently maintains only a forward map from route-pattern to controller/action-name, with this feature, it would (internally?) maintain a reverse map of controller/action-name to route-pattern.

The ability to perform a reverse look-up enables us to template the URL patterns and create URLs, which either (A) eliminates maintenance of synchronous URL creation (matching defined routes) in hand-written URL helpers, or (B) eliminates hand-written URL helpers entirely, depending on developer preference.

TBD: Milestone 2.x or 3.0?

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

1 participant