Skip to content

Commit 0502677

Browse files
committed
Merge branch '4.4'
* 4.4: Update and fix Routing page Documentation
2 parents d597dae + 5643853 commit 0502677

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

routing.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ and in route imports. Symfony defines some special attributes with the same name
877877
.. code-block:: php-annotations
878878
879879
// src/Controller/ArticleController.php
880+
namespace App\Controller;
880881
881882
// ...
882883
class ArticleController extends AbstractController
@@ -960,6 +961,9 @@ the controllers of the routes:
960961

961962
.. code-block:: php-annotations
962963
964+
// src/Controller/BlogController.php
965+
namespace App\Controller;
966+
963967
use Symfony\Component\Routing\Annotation\Route;
964968
965969
class BlogController
@@ -1030,6 +1034,9 @@ A possible solution is to change the parameter requirements to be more permissiv
10301034

10311035
.. code-block:: php-annotations
10321036
1037+
// src/Controller/DefaultController.php
1038+
namespace App\Controller;
1039+
10331040
use Symfony\Component\Routing\Annotation\Route;
10341041
10351042
class DefaultController
@@ -1115,6 +1122,9 @@ the common configuration using options when importing the routes.
11151122

11161123
.. code-block:: php-annotations
11171124
1125+
// src/Controller/BlogController.php
1126+
namespace App\Controller;
1127+
11181128
use Symfony\Component\Routing\Annotation\Route;
11191129
11201130
/**
@@ -1131,7 +1141,7 @@ the common configuration using options when importing the routes.
11311141
}
11321142
11331143
/**
1134-
* @Route("/{_locale}/posts/{slug}", name="post")
1144+
* @Route("/{_locale}/posts/{slug}", name="show")
11351145
*/
11361146
public function show(Post $post)
11371147
{
@@ -1207,7 +1217,7 @@ the common configuration using options when importing the routes.
12071217
12081218
In this example, the route of the ``index()`` action will be called ``blog_index``
12091219
and its URL will be ``/blog/``. The route of the ``show()`` action will be called
1210-
``blog_post`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes
1220+
``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes
12111221
will also validate that the ``_locale`` parameter matches the regular expression
12121222
defined in the class annotation.
12131223

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

18241834
// src/Service/SomeService.php
1835+
namespace App\Service;
1836+
18251837
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18261838

18271839
class SomeService
@@ -1927,6 +1939,8 @@ generate URLs. This context can be configured globally for all commands:
19271939
This information can be configured per command too::
19281940

19291941
// src/Command/SomeCommand.php
1942+
namespace App\Command;
1943+
19301944
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
19311945
use Symfony\Component\Routing\RouterInterface;
19321946
// ...
@@ -2059,7 +2073,7 @@ each route explicitly:
20592073
# config/routes.yaml
20602074
login:
20612075
path: /login
2062-
controller: App\Controller\SeurityController::login
2076+
controller: App\Controller\SecurityController::login
20632077
schemes: [https]
20642078
20652079
.. code-block:: xml

0 commit comments

Comments
 (0)