Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 88298ed

Browse filesBrowse files
committed
minor #20466 [HttpFoundation] Add StreamedResponse string iterable (mtarld)
This PR was merged into the 7.3 branch. Discussion ---------- [HttpFoundation] Add `StreamedResponse` string iterable Fix #20462 Document the support of string iterable in `StreamedResponse`. Commits ------- f87bbdf [HttpFoundation] Add StreamedResponse string iterable documentation
2 parents f6edd63 + f87bbdf commit 88298ed
Copy full SHA for 88298ed

File tree

1 file changed

+17
-2
lines changed
Filter options

1 file changed

+17
-2
lines changed

‎components/http_foundation.rst

Copy file name to clipboardExpand all lines: components/http_foundation.rst
+17-2Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,19 @@ Streaming a Response
681681
~~~~~~~~~~~~~~~~~~~~
682682

683683
The :class:`Symfony\\Component\\HttpFoundation\\StreamedResponse` class allows
684-
you to stream the Response back to the client. The response content is
685-
represented by a PHP callable instead of a string::
684+
you to stream the Response back to the client. The response content can be
685+
represented by a string iterable::
686+
687+
use Symfony\Component\HttpFoundation\StreamedResponse;
688+
689+
$chunks = ['Hello', ' World'];
690+
691+
$response = new StreamedResponse();
692+
$response->setChunks($chunks);
693+
$response->send();
694+
695+
For most complex use cases, the response content can be instead represented by
696+
a PHP callable::
686697

687698
use Symfony\Component\HttpFoundation\StreamedResponse;
688699

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

724+
.. versionadded:: 7.3
725+
726+
Support for using string iterables was introduced in Symfony 7.3.
727+
713728
Streaming a JSON Response
714729
~~~~~~~~~~~~~~~~~~~~~~~~~
715730

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.