@@ -5,12 +5,12 @@ How to Allow a "/" Character in a Route Parameter
5
5
=================================================
6
6
7
7
Sometimes, 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,
9
9
``/hello/Fabien `` will match this route but not ``/hello/Fabien/Kris ``. This
10
10
is because Symfony uses this character as separator between route parts.
11
11
12
12
This 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 ``.
14
14
15
15
Configure the Route
16
16
-------------------
@@ -27,10 +27,10 @@ a more permissive regex path.
27
27
.. code-block :: yaml
28
28
29
29
_hello :
30
- path : /hello/{userName }
30
+ path : /hello/{username }
31
31
defaults : { _controller: AcmeDemoBundle:Demo:hello }
32
32
requirements :
33
- userName : .+
33
+ username : .+
34
34
35
35
.. code-block :: xml
36
36
@@ -40,9 +40,9 @@ a more permissive regex path.
40
40
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
41
41
xsi : schemaLocation =" http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd" >
42
42
43
- <route id =" _hello" path =" /hello/{userName }" >
43
+ <route id =" _hello" path =" /hello/{username }" >
44
44
<default key =" _controller" >AcmeDemoBundle:Demo:hello</default >
45
- <requirement key =" userName " >.+</requirement >
45
+ <requirement key =" username " >.+</requirement >
46
46
</route >
47
47
</routes >
48
48
@@ -52,10 +52,10 @@ a more permissive regex path.
52
52
use Symfony\Component\Routing\Route;
53
53
54
54
$collection = new RouteCollection();
55
- $collection->add('_hello', new Route('/hello/{userName }', array(
55
+ $collection->add('_hello', new Route('/hello/{username }', array(
56
56
'_controller' => 'AcmeDemoBundle:Demo:hello',
57
57
), array(
58
- 'userName ' => '.+',
58
+ 'username ' => '.+',
59
59
)));
60
60
61
61
return $collection;
@@ -75,4 +75,4 @@ a more permissive regex path.
75
75
}
76
76
}
77
77
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