Permalink
Browse files

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
  • Loading branch information...
weaverryan committed Nov 20, 2014
2 parents c008733 + b412780 commit 188dd1f17f96c7d31950ba30314683fae0614ba3
Showing with 9 additions and 9 deletions.
  1. +9 −9 cookbook/routing/slash_in_parameter.rst
@@ -5,12 +5,12 @@ How to Allow a "/" Character in a Route Parameter
=================================================
Sometimes, you need to compose URLs with parameters that can contain a slash
``/``. For example, take the classic ``/hello/{name}`` route. By default,
``/``. For example, take the classic ``/hello/{username}`` route. By default,
``/hello/Fabien`` will match this route but not ``/hello/Fabien/Kris``. This
is because Symfony uses this character as separator between route parts.
This guide covers how you can modify a route so that ``/hello/Fabien/Kris``
matches the ``/hello/{name}`` route, where ``{name}`` equals ``Fabien/Kris``.
matches the ``/hello/{username}`` route, where ``{username}`` equals ``Fabien/Kris``.
Configure the Route
-------------------
@@ -27,10 +27,10 @@ a more permissive regex path.
.. code-block:: yaml
_hello:
path: /hello/{name}
path: /hello/{username}
defaults: { _controller: AcmeDemoBundle:Demo:hello }
requirements:
name: .+
username: .+
.. code-block:: xml
@@ -40,9 +40,9 @@ a more permissive regex path.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="_hello" path="/hello/{name}">
<route id="_hello" path="/hello/{username}">
<default key="_controller">AcmeDemoBundle:Demo:hello</default>
<requirement key="name">.+</requirement>
<requirement key="username">.+</requirement>
</route>
</routes>
@@ -52,10 +52,10 @@ a more permissive regex path.
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('_hello', new Route('/hello/{name}', array(
$collection->add('_hello', new Route('/hello/{username}', array(
'_controller' => 'AcmeDemoBundle:Demo:hello',
), array(
'name' => '.+',
'username' => '.+',
)));
return $collection;
@@ -75,4 +75,4 @@ a more permissive regex path.
}
}
That's it! Now, the ``{name}`` parameter can contain the ``/`` character.
That's it! Now, the ``{username}`` parameter can contain the ``/`` character.

0 comments on commit 188dd1f

Please sign in to comment.