diff --git a/app-test/_includes/AppTest.php b/app-test/_includes/AppTest.php index 6053f37..31e6ef5 100644 --- a/app-test/_includes/AppTest.php +++ b/app-test/_includes/AppTest.php @@ -30,6 +30,7 @@ public static function createPage(string $environment = 'production'): Page ]); if ($environment === 'dev') { + $page->fohnJsVersion = ''; $page->includeJsPackage('fohn-js', '/public/fohn-ui.js'); $page->includeCssPackage('fohn-css', '/public/fohn-ui.css'); } diff --git a/src/App.php b/src/App.php index 0d8f375..2beed95 100644 --- a/src/App.php +++ b/src/App.php @@ -186,6 +186,7 @@ public function prepareEventStreaming(int $limit = 0, bool $ignoreUserAbort = tr { @set_time_limit($limit); ignore_user_abort($ignoreUserAbort); + @ini_set('zlib.output_compression', '0'); $response = (new Response()) ->withHeader('Content-Type', 'text/event-stream') diff --git a/src/Callback/ServerEvent.php b/src/Callback/ServerEvent.php index fab1d14..a5f18e7 100644 --- a/src/Callback/ServerEvent.php +++ b/src/Callback/ServerEvent.php @@ -38,6 +38,12 @@ class ServerEvent extends Generic /** Keep execution alive or not if connection is close by user. False mean that execution will stop on user aborted. */ public bool $keepAlive = false; + /** + * The min size of event stream data to be output. + * Set it to 4096 when using phpfpm. + */ + public int $minBufferSize = 0; + /** Check if ServerEvent callback has been request and executed. */ private bool $requestSet = false; @@ -127,7 +133,7 @@ protected function sendBlock(string $id, string $event, string $name): void $streamEvent = [ 'id: ' . $id . "\n", 'event: ' . $name . "\n", - 'data' => $this->wrapEvent($event) . "\n", + 'data' => $this->wrapEvent(str_pad($event, $this->minBufferSize)) . "\n", ]; $this->app->streamEvent($streamEvent);