Skip to content

Commit a647e16

Browse files
committed
Added a note about the use of _format query parameter
1 parent ea2503c commit a647e16

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

book/routing.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,12 +1028,20 @@ a slash. URLs matching this route might look like:
10281028

10291029
This example also highlights the special ``_format`` routing parameter.
10301030
When using this parameter, the matched value becomes the "request format"
1031-
of the ``Request`` object. Ultimately, the request format is used for such
1032-
things as setting the ``Content-Type`` of the response (e.g. a ``json``
1033-
request format translates into a ``Content-Type`` of ``application/json``).
1034-
It can also be used in the controller to render a different template for
1035-
each value of ``_format``. The ``_format`` parameter is a very powerful way
1036-
to render the same content in different formats.
1031+
of the ``Request`` object.
1032+
1033+
Ultimately, the request format is used for such things as setting the
1034+
``Content-Type`` of the response (e.g. a ``json`` request format translates
1035+
into a ``Content-Type`` of ``application/json``). It can also be used in the
1036+
controller to render a different template for each value of ``_format``.
1037+
The ``_format`` parameter is a very powerful way to render the same content
1038+
in different formats.
1039+
1040+
In Symfony versions previous to 3.0, it is possible to override the request
1041+
format by adding a query parameter named ``_format`` (for example:
1042+
``/foo/bar?_format=json``). Relying on this behavior not only is considered
1043+
a bad practice but it will complicate the upgrade of your applications to
1044+
Symfony 3.
10371045

10381046
.. note::
10391047

0 commit comments

Comments
 (0)