Last Updated: September 09, 2019
·
4.48K
· andreia

Symfony2 Routing: Trailing slash with an optional parameter

my_route:
    pattern:  /blog/{var}
    defaults: { _controller: TestBundle:Blog:index, var: ''}
    requirements:
        var: ".*"

Match:

/blog
/blog/
/blog/1

1 Response
Add your response

Hello Andreia,
One thing I have a default value?

hello_homepage:
    pattern:  /hello/{name}
    defaults: { _controller: HelloBundle:Default:index, name: Carlos }
    requirements:
      name: ".*"

How I can do to show name default in myapp.com/hello/ ?

Thanks!!!

over 1 year ago ·