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

Multiple optional parameters #55

Closed
akrabat opened this issue Jun 18, 2015 · 6 comments
Closed

Multiple optional parameters #55

akrabat opened this issue Jun 18, 2015 · 6 comments

Comments

@akrabat
Copy link

akrabat commented Jun 18, 2015

Thanks for implementing the support of optional parameters.

How does multiple optional work? e.g. /news[/{year}][/{month}] gives:

Fatal error: Uncaught exception 'FastRoute\BadRouteException' with message 'Number of opening '['
and closing ']' does not match' in 
/www/dev/slim3/develop-testbed/vendor/nikic/fast-route/src/RouteParser/Std.php on line 31

Am I using the wrong syntax?

@akrabat
Copy link
Author

akrabat commented Jun 18, 2015

To follow up, nesting the square brackets is the solution. i.e. /news[/{year}[/{month}]]

@akrabat akrabat closed this as completed Jun 18, 2015
@dopesong
Copy link

@nikic I think this should be mentioned in docs.

@renb0
Copy link

renb0 commented Oct 8, 2015

Yes it really should, i came here from Google.

@digitalnature
Copy link

me too :)

@nikic
Copy link
Owner

nikic commented Apr 18, 2016

I've added an example to the README: 79843dc

@sandeepnanda2
Copy link

sandeepnanda2 commented Dec 24, 2018

@nikic I'm using Slim framework,
in Routes.php my code looks like
$app->get('/stores/[{storeName}]/categories', 'CategoryController:GETCategories');
I need to add {storeName} as mandatory variable but when I add the above pattern it is giving the following error.

Type: FastRoute\BadRouteException
Message: Optional segments can only occur at the end of a route

Could you please help to solve this issue, suggest me a solution how to use fastRoute in slim.

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

6 participants