Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clarify routing documentation on trailing optional parameters #1873

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

Closed
wants to merge 3 commits into from
Closed

Clarify routing documentation on trailing optional parameters #1873

wants to merge 3 commits into from

Conversation

chrismcmacken
Copy link
Contributor

As noted in issue symfony/symfony#5869 the Routing documentation is a little unclear as to when routes with optional parameters at the end are matched.

my_test_homepage:
    pattern:  /hello/{name}
    defaults: { _controller: MyTestBundle:Default:index, name: DefaultName }

The above route will only match on /hello and /hello/name, it will not match /hello/. I would like to clarify this in the documentation to avoid any confusion in the future.


Routes with optional parameters at the end will not match on requests
with a trailing slash (i.e. /blog/). In this case the slash is a separator and
should not be used if the optional parameter isn't passed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each line should be indented by 4 spaces

.. tip::

Routes with optional parameters at the end will not match on requests
with a trailing slash (i.e. /blog/). In this case the slash is a separator and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a double backtick around /blog/:

with a trailing slash (i.e. ``/blog/``). In this case the slash is a seperator and

@weaverryan
Copy link
Member

Hi Chris!

This is an excellent addition! Since this affects all branches, I've merged it in at the following commits:

Thanks for your contribution!

@weaverryan weaverryan closed this Nov 17, 2012
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

Successfully merging this pull request may close these issues.

3 participants