@@ -5,12 +5,12 @@ How to Allow a "/" Character in a Route Parameter
55=================================================
66
77Sometimes, you need to compose URLs with parameters that can contain a slash
8- ``/ ``. For example, take the classic ``/hello/{userName } `` route. By default,
8+ ``/ ``. For example, take the classic ``/hello/{username } `` route. By default,
99``/hello/Fabien `` will match this route but not ``/hello/Fabien/Kris ``. This
1010is because Symfony uses this character as separator between route parts.
1111
1212This guide covers how you can modify a route so that ``/hello/Fabien/Kris ``
13- matches the ``/hello/{userName } `` route, where ``{userName } `` equals ``Fabien/Kris ``.
13+ matches the ``/hello/{username } `` route, where ``{username } `` equals ``Fabien/Kris ``.
1414
1515Configure the Route
1616-------------------
@@ -27,10 +27,10 @@ a more permissive regex path.
2727 .. code-block :: yaml
2828
2929 _hello :
30- path : /hello/{userName }
30+ path : /hello/{username }
3131 defaults : { _controller: AcmeDemoBundle:Demo:hello }
3232 requirements :
33- userName : .+
33+ username : .+
3434
3535 .. code-block :: xml
3636
@@ -40,9 +40,9 @@ a more permissive regex path.
4040 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4141 xsi : schemaLocation =" http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd" >
4242
43- <route id =" _hello" path =" /hello/{userName }" >
43+ <route id =" _hello" path =" /hello/{username }" >
4444 <default key =" _controller" >AcmeDemoBundle:Demo:hello</default >
45- <requirement key =" userName " >.+</requirement >
45+ <requirement key =" username " >.+</requirement >
4646 </route >
4747 </routes >
4848
@@ -52,10 +52,10 @@ a more permissive regex path.
5252 use Symfony\Component\Routing\Route;
5353
5454 $collection = new RouteCollection();
55- $collection->add('_hello', new Route('/hello/{userName }', array(
55+ $collection->add('_hello', new Route('/hello/{username }', array(
5656 '_controller' => 'AcmeDemoBundle:Demo:hello',
5757 ), array(
58- 'userName ' => '.+',
58+ 'username ' => '.+',
5959 )));
6060
6161 return $collection;
@@ -75,4 +75,4 @@ a more permissive regex path.
7575 }
7676 }
7777
78- That's it! Now, the ``{userName } `` parameter can contain the ``/ `` character.
78+ That's it! Now, the ``{username } `` parameter can contain the ``/ `` character.
0 commit comments