dkvzaw
Last Updated: February 25, 2016
·
4.019K
· 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

12996

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 ·