Skip to content

[v4] Enable output buffering like php.ini-production - #369

Merged
mnapoli merged 1 commit into
4.xfrom
output-buffering
Nov 27, 2026
Merged

mnapoli merged 1 commit into
4.xfrom
output-buffering

Conversation

@mnapoli

@mnapoli mnapoli commented Nov 27, 2026

Copy link
Copy Markdown
Member

Bref's php.ini does not set output_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(); in response()->stream()) stops after its first chunk on PHP-FPM.

Tested on Lambda (published v4 runtime, output_buffering=4096 set through php/conf.d):

  • Laravel's ob_flush(); flush(); example streams (chunks 300 ms apart), SSE and the early end before the timeout still work,
  • code that only calls flush() with chunks under 4 KB is sent at the end, as with php.ini-production on any PHP-FPM server,
  • Octane and the Symfony kernel are unaffected (the CLI ignores the setting).

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.
@mnapoli mnapoli self-assigned this Nov 27, 2026
@mnapoli
mnapoli merged commit 5f8a916 into 4.x Nov 27, 2026
9 checks passed
@mnapoli
mnapoli deleted the output-buffering branch November 27, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant