Skip to content

Update and fix Routing page Documentation #12506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ and in route imports. Symfony defines some special attributes with the same name
.. code-block:: php-annotations

// src/Controller/ArticleController.php

namespace App\Controller;

// ...
class ArticleController extends AbstractController
{
Expand Down Expand Up @@ -969,6 +970,9 @@ the controllers of the routes:

.. code-block:: php-annotations

// src/Controller/BlogController.php
namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;

class BlogController
Expand Down Expand Up @@ -1039,6 +1043,9 @@ A possible solution is to change the parameter requirements to be more permissiv

.. code-block:: php-annotations

// src/Controller/DefaultController.php
namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;

class DefaultController
Expand Down Expand Up @@ -1123,7 +1130,9 @@ the common configuration using options when importing the routes.
.. configuration-block::

.. code-block:: php-annotations

// src/Controller/BlogController.php
namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;

/**
Expand All @@ -1140,7 +1149,7 @@ the common configuration using options when importing the routes.
}

/**
* @Route("/{_locale}/posts/{slug}", name="post")
* @Route("/{_locale}/posts/{slug}", name="show")
*/
public function show(Post $post)
{
Expand Down Expand Up @@ -1216,7 +1225,7 @@ the common configuration using options when importing the routes.

In this example, the route of the ``index()`` action will be called ``blog_index``
and its URL will be ``/blog/``. The route of the ``show()`` action will be called
``blog_post`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes
``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes
will also validate that the ``_locale`` parameter matches the regular expression
defined in the class annotation.

Expand Down Expand Up @@ -1832,6 +1841,8 @@ you only need to add an argument in the service constructor and type-hint it wit
the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class::

// src/Service/SomeService.php
namespace App\Service;

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class SomeService
Expand Down Expand Up @@ -1937,6 +1948,8 @@ generate URLs. This context can be configured globally for all commands:
This information can be configured per command too::

// src/Command/SomeCommand.php
namespace App\Command;

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
// ...
Expand Down Expand Up @@ -2069,7 +2082,7 @@ each route explicitly:
# config/routes.yaml
login:
path: /login
controller: App\Controller\SeurityController::login
controller: App\Controller\SecurityController::login
schemes: [https]

.. code-block:: xml
Expand Down