Repository navigation
[v4] Enable output buffering like php.ini-production - #369
Merged
Merged
Conversation
Without a buffer, ob_flush() raises "failed to flush buffer. No buffer to flush", which Laravel turns into an exception: its documented streamed response (`ob_flush(); flush();`) stops after the first chunk on PHP-FPM. php.ini-production sets output_buffering=4096, which is what applications expect from a usual PHP-FPM setup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bref's
php.inidoes not setoutput_buffering, so PHP uses its built-in default: no buffer.php.ini-production(what a usual nginx/Apache + PHP-FPM setup uses) sets 4096.Now that v4 streams responses, it matters: with no buffer,
ob_flush()raises "failed to flush buffer. No buffer to flush", which Laravel turns into an exception. Laravel's documented streamed response (ob_flush(); flush();inresponse()->stream()) stops after its first chunk on PHP-FPM.Tested on Lambda (published v4 runtime,
output_buffering=4096set throughphp/conf.d):ob_flush(); flush();example streams (chunks 300 ms apart), SSE and the early end before the timeout still work,flush()with chunks under 4 KB is sent at the end, as with php.ini-production on any PHP-FPM server,