From 3d5b4a3499d8cfbac14dce6b2bc1caeaa98a7e8a Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 27 Nov 2026 11:47:17 +0100 Subject: [PATCH] Enable output buffering like php.ini-production 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. --- src/php.ini | 5 +++++ tests/test_5_fpm_handler.php | 1 + tests/test_5_fpm_invocation.php | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/php.ini b/src/php.ini index 5c75488e..dfe22ae2 100644 --- a/src/php.ini +++ b/src/php.ini @@ -14,6 +14,11 @@ memory_limit=10240M ; The CLI already has no limit. max_execution_time=0 +; Like php.ini-production: PHP-FPM keeps up to 4 KB of output before sending it, and ob_flush() +; works in streamed responses (e.g. Laravel's `ob_flush(); flush();`, which fails without a buffer). +; The CLI ignores this setting. +output_buffering=4096 + opcache.enable=1 opcache.enable_cli=1 diff --git a/tests/test_5_fpm_handler.php b/tests/test_5_fpm_handler.php index 7da7d762..9e6572ae 100644 --- a/tests/test_5_fpm_handler.php +++ b/tests/test_5_fpm_handler.php @@ -1,6 +1,7 @@