I have some long processing in loop and want to output progress contiguously.
while (true)
{
$percents = $do_my_stuff();
echo $percents;
$this->log($percents);
}
I have tried many techniques, but still no luck
ini_set('output_buffering', 'off');
ini_set('zlib.output_compression', false);
while (@ob_end_flush());
ini_set('implicit_flush', true);
ob_implicit_flush(true);
flush()
in each cycle
wrap loop in
$this->response->body(function () { /* loop with echo here */ }
but still browser displays all data once when script finished. Response headers:
HTTP/1.1 200 OK
Host: localhost:8765
Connection: close
X-Powered-By: PHP/5.6.20
Content-type: text/html; charset=UTF-8
PHP 5.6, built-in server using ./bin/cake server
, CakePHP 3
How can i do that? I want my users see percents of operation because it can run for a long time.