From 883d23f993182a7a41124f4a733739aa4afc8b34 Mon Sep 17 00:00:00 2001 From: SamanShafigh Date: Thu, 9 Oct 2014 16:23:02 +1100 Subject: [PATCH] Update slash_in_parameter.rst "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 requirements: name: .+ --- cookbook/routing/slash_in_parameter.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cookbook/routing/slash_in_parameter.rst b/cookbook/routing/slash_in_parameter.rst index 64f1a27c08d..b760a81a407 100644 --- a/cookbook/routing/slash_in_parameter.rst +++ b/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"> - + AcmeDemoBundle:Demo:hello - .+ + .+ @@ -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.