Skip to content

Commit 6b75287

Browse files
committed
minor #20411 update controller return value (Florian-Merle)
This PR was merged into the 5.4 branch. Discussion ---------- update controller return value A controller is not required to return a `Response` object anymore. Commits ------- 42b4c95 update controller return value doc
2 parents 29c83bd + 42b4c95 commit 6b75287

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

controller.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ and provides methods for getting and setting response headers. The header names
447447
normalized. As a result, the name ``Content-Type`` is equivalent to
448448
the name ``content-type`` or ``content_type``.
449449

450-
In Symfony, a controller is required to return a ``Response`` object::
450+
In Symfony, a controller usually returns a ``Response`` object::
451451

452452
use Symfony\Component\HttpFoundation\Response;
453453

@@ -463,6 +463,14 @@ response types. Some of these are mentioned below. To learn more about the
463463
``Request`` and ``Response`` (and different ``Response`` classes), see the
464464
:ref:`HttpFoundation component documentation <component-http-foundation-request>`.
465465

466+
.. note::
467+
468+
When a controller returns a non-``Response`` object, a ``kernel.view``
469+
listener is expected to transform it into a ``Response`` object;
470+
otherwise an exception is thrown.
471+
472+
See :ref:`kernel.view event <component-http-kernel-kernel-view>` for details on the ``kernel.view`` event.
473+
466474
Accessing Configuration Values
467475
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
468476

0 commit comments

Comments
 (0)