diff --git a/README.md b/README.md index f981084..f4e7422 100644 --- a/README.md +++ b/README.md @@ -440,27 +440,32 @@ while ( $client->hasUnhandledResponses() ) 1 ``` -### Reading request as it goes back piece by piece (pass-through) +### Reading output buffer from worker script using pass through callbacks -It may be useful to see the progression of a request, such as a batch. Say you have a PHP script like: +It may be useful to see the progression of a requested script by having access to the flushed output of that script. +The php.ini default output buffering for php-fpm is 4096 bytes and is (hard-coded) disabled for CLI mode. ([See documentation](http://php.net/manual/en/outcontrol.configuration.php#ini.output-buffering)) +Calling `ob_implicit_flush()` causes every call to `echo` or `print` to immediately be flushed. + +The callee script could look like this: ```php - '1', 'sleep' => 3])); -$request->addPassThroughCallbacks($passThroughCallback); +$request = new GetRequest('/path/to/target/script.php', ''); +$request->addPassThroughCallbacks( $passThroughCallback ); $client->sendAsyncRequest($request); $client->waitForResponses(); ``` -Call the batch script in your console: -``` -php /path/to/batch/caller.php -``` - ``` # prints immediately -Very long script to run -# after first task is done -First long task ended -# after second task is done -Second long task ended -End of script +Buffer: Content-type: text/html; charset=UTF-8 + +One +# sleeps 1 sec +Buffer: Two +# sleeps 1 sec +Buffer: Three +# sleeps 1 sec +Buffer: End ``` ----