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

Routing system: add route globbing and wildcard segments #36

Closed
AnthonySnow887 opened this issue May 19, 2022 · 1 comment
Closed

Routing system: add route globbing and wildcard segments #36

AnthonySnow887 opened this issue May 19, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@AnthonySnow887
Copy link
Owner

Route globbing is a way to specify that a particular parameter should be matched to all the remaining parts of a route. For example:

get('photos/*other', [ 'to' => 'photos#unknown' ]);

This route would match photos/12 or /photos/long/path/to/12, setting _params['other'] to "12" or "long/path/to/12". The segments prefixed with a star are called "wildcard segments".

Wildcard segments can occur anywhere in a route. For example:

get('books/*section/:title', [ 'to' => 'books#show' ]);

would match books/some/section/last-words-a-memoir with _params['section'] equals 'some/section', and _params['title'] equals 'last-words-a-memoir'.

Technically, a route can have even more than one wildcard segment. The matcher assigns segments to parameters in an intuitive way. For example:

get('*a/foo/*b', [ 'to' => 'test#index' ]);

would match zoo/woo/foo/bar/baz with _params['a'] equals 'zoo/woo', and _params['b'] equals 'bar/baz'.

@AnthonySnow887 AnthonySnow887 added the enhancement New feature or request label May 19, 2022
@AnthonySnow887
Copy link
Owner Author

RUS

Добавлено в коммите aa42f25

ENG

Added in commit aa42f25

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

No branches or pull requests

1 participant