Skip to content

Commit 188dd1f

Browse files
committed
minor #4400 Continues #4307 (SamanShafigh, WouterJ)
This PR was merged into the 2.3 branch. Discussion ---------- Continues #4307 Continues #4307 | Q | A | --- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | - Original PR description: > "name" in requirements is confusing, I had problem for doing the same and then after 2 days I found that the "name" should be same as the parameter, it is not part of symfony config Commits ------- b412780 Changed userName to username 48f453d Update slash_in_parameter.rst
2 parents c008733 + b412780 commit 188dd1f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cookbook/routing/slash_in_parameter.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ How to Allow a "/" Character in a Route Parameter
55
=================================================
66

77
Sometimes, you need to compose URLs with parameters that can contain a slash
8-
``/``. For example, take the classic ``/hello/{name}`` 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
1010
is because Symfony uses this character as separator between route parts.
1111

1212
This guide covers how you can modify a route so that ``/hello/Fabien/Kris``
13-
matches the ``/hello/{name}`` route, where ``{name}`` equals ``Fabien/Kris``.
13+
matches the ``/hello/{username}`` route, where ``{username}`` equals ``Fabien/Kris``.
1414

1515
Configure the Route
1616
-------------------
@@ -27,10 +27,10 @@ a more permissive regex path.
2727
.. code-block:: yaml
2828
2929
_hello:
30-
path: /hello/{name}
30+
path: /hello/{username}
3131
defaults: { _controller: AcmeDemoBundle:Demo:hello }
3232
requirements:
33-
name: .+
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/{name}">
43+
<route id="_hello" path="/hello/{username}">
4444
<default key="_controller">AcmeDemoBundle:Demo:hello</default>
45-
<requirement key="name">.+</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/{name}', array(
55+
$collection->add('_hello', new Route('/hello/{username}', array(
5656
'_controller' => 'AcmeDemoBundle:Demo:hello',
5757
), array(
58-
'name' => '.+',
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 ``{name}`` parameter can contain the ``/`` character.
78+
That's it! Now, the ``{username}`` parameter can contain the ``/`` character.

0 commit comments

Comments
 (0)