Skip to content

[HttpFoundation] Support iterable of string in StreamedResponse #59154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Dec 10, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Improve DX by supporting iterable of string in StreamedResponse so that it's more convenient streaming a list of strings.

Before:

$iterable = ['foo, 'bar', 'baz'];
$response = new StreamedResponse(function () use ($iterable): void {
    foreach ($iterable as $chunk) {
        echo $chunk;
    }
});

After:

$iterable = ['foo, 'bar', 'baz'];
$response = new StreamedResponse($iterable);

@mtarld mtarld force-pushed the feat/streamed-response-iterable branch from 36c8cb7 to 7e4178a Compare December 10, 2024 12:42
@fabpot
Copy link
Member

fabpot commented Dec 10, 2024

Thank you @mtarld.

@fabpot fabpot merged commit cfe09c2 into symfony:7.3 Dec 10, 2024
8 of 11 checks passed
@mtarld mtarld deleted the feat/streamed-response-iterable branch December 10, 2024 17:31
@fabpot fabpot mentioned this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants