Skip to content

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