Skip to content
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
19 changes: 17 additions & 2 deletions components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,19 @@ Streaming a Response
~~~~~~~~~~~~~~~~~~~~

The :class:`Symfony\\Component\\HttpFoundation\\StreamedResponse` class allows
you to stream the Response back to the client. The response content is
represented by a PHP callable instead of a string::
you to stream the Response back to the client. The response content can be
represented by a string iterable::

use Symfony\Component\HttpFoundation\StreamedResponse;

$chunks = ['Hello', ' World'];

$response = new StreamedResponse();
$response->setChunks($chunks);
$response->send();

For most complex use cases, the response content can be instead represented by
a PHP callable::

use Symfony\Component\HttpFoundation\StreamedResponse;

Expand Down Expand Up @@ -710,6 +721,10 @@ represented by a PHP callable instead of a string::
// disables FastCGI buffering in nginx only for this response
$response->headers->set('X-Accel-Buffering', 'no');

.. versionadded:: 7.3

Support for using string iterables was introduced in Symfony 7.3.

Streaming a JSON Response
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading