|
4 | 4 | Routing
|
5 | 5 | =======
|
6 | 6 |
|
7 |
| -When your application receives an HTTP request, it executes some |
| 7 | +When your application receives an HTTP request, it executes a |
8 | 8 | :doc:`controller action </controller>` to generate the HTTP response. The
|
9 | 9 | routing configuration defines which action to run for each incoming URL. It also
|
10 |
| -provides other useful features, such as generating SEO-friendly URLs |
| 10 | +provides other useful features, like generating SEO-friendly URLs |
11 | 11 | (e.g. ``/read/intro-to-symfony`` instead of ``index.php?article_id=57``).
|
12 | 12 |
|
13 | 13 | Creating Routes
|
14 | 14 | ---------------
|
15 | 15 |
|
16 | 16 | Routes can be configured in YAML, XML, PHP or using annotations. All formats
|
17 |
| -provide the same features and performance, so choose the one you prefer. |
18 |
| -:doc:`Symfony recommends to use annotations </best_practices/controllers>` |
19 |
| -because it's convenient to put the route definition and its controller in the |
20 |
| -same place instead of having to deal with multiple files. |
| 17 | +provide the same features and performance, so choose your favorite. |
| 18 | +:doc:`Symfony recommends annotations </best_practices/controllers>` |
| 19 | +because it's convenient to put the route and controller in the |
| 20 | +same place instead of dealing with multiple files. |
21 | 21 |
|
22 |
| -If you choose PHP annotations, run this command once in your application to add |
| 22 | +If you choose annotations, run this command once in your application to add |
23 | 23 | support for them:
|
24 | 24 |
|
25 | 25 | .. code-block:: terminal
|
@@ -106,14 +106,14 @@ the ``list()`` method of the ``BlogController`` class.
|
106 | 106 | example, URLs like ``/blog?foo=bar`` and ``/blog?foo=bar&bar=foo`` will
|
107 | 107 | also match the ``blog_list`` route.
|
108 | 108 |
|
109 |
| -The route name is not important for now, but it will be essential later when |
| 109 | +The route name (``blog_list``) is not important for now, but it will be essential later when |
110 | 110 | :ref:`generating URLs <routing-generating-urls>`. You only have to keep in mind
|
111 |
| -that names can be chosen freely but they must be unique in the application. |
| 111 | +that each route name must be unique in the application. |
112 | 112 |
|
113 | 113 | Route HTTP Methods
|
114 | 114 | ~~~~~~~~~~~~~~~~~~
|
115 | 115 |
|
116 |
| -By default, routes respond to any HTTP verb (``GET``, ``POST``, ``PUT``, etc.) |
| 116 | +By default, routes match any HTTP verb (``GET``, ``POST``, ``PUT``, etc.) |
117 | 117 | Use the ``methods`` option to restrict the verbs each route should respond to:
|
118 | 118 |
|
119 | 119 | .. configuration-block::
|
@@ -194,7 +194,7 @@ Use the ``methods`` option to restrict the verbs each route should respond to:
|
194 | 194 |
|
195 | 195 | .. tip::
|
196 | 196 |
|
197 |
| - HTML forms only support ``GET`` and ``POST`` methods. If you are calling a |
| 197 | + HTML forms only support ``GET`` and ``POST`` methods. If you're calling a |
198 | 198 | route with a different method from an HTML form, add a hidden field called
|
199 | 199 | ``_method`` with the method to use (e.g. ``<input type="hidden" name="_method" value="PUT" />``).
|
200 | 200 | If you use :doc:`Symfony forms </forms>` this is done automatically for you.
|
@@ -332,13 +332,13 @@ with a locale. This can be done by defining a different prefix for each locale
|
332 | 332 | Route Groups
|
333 | 333 | ~~~~~~~~~~~~
|
334 | 334 |
|
335 |
| -It's common for routes to share some features and options (e.g. all routes |
| 335 | +It's common for a group of routes to share some options (e.g. all routes |
336 | 336 | related to the blog start with ``/blog``; all routes validate the locale with
|
337 | 337 | the same regular expression; etc.) That's why Symfony includes a feature to
|
338 |
| -share the routes configuration. |
| 338 | +share route configuration. |
339 | 339 |
|
340 |
| -When defining routes as annotations, add a ``@Route`` annotation to the |
341 |
| -controller class to apply some options to all the routes defined in that class:: |
| 340 | +When defining routes as annotations, add an ``@Route`` annotation to the |
| 341 | +controller class to apply options to all the routes defined in that class:: |
342 | 342 |
|
343 | 343 | use Symfony\Component\Routing\Annotation\Route;
|
344 | 344 |
|
|
0 commit comments