[eluser]CroNiX[/eluser]
Here's a helper I created to do that:
Code:
//kill CI's buffered output and stream realtime
if ( ! function_exists('kill_buffer'))
{
function kill_buffer()
{
$CI =& get_instance();
//output any CI output up til now
echo $CI->output->get_output();
//output/wipe buffer and enable implcit flush
@ob_end_flush();
ob_implicit_flush(TRUE);
//For some reason about 1kb needs to be sent before realtime output shows up. Just send a bunch of spaces in a hidden div.
echo '<div >' . str_repeat(' ', 170) . '</div>';
//No headers beyond this point unless they are sent FIRST...
}
}
Depending on your usage, you might need to adjust the very last output (like you wouldn't want to output html to the CLI), but I use it in a browser so that's how I wrote it.
To test you could just do:
Code:
kill_buffer();
for ($x = 0; $x < 5; $x++)
{
echo date('H:i:s') . '<br>';
sleep(1);
}
should write the time in real time to the browser 5 times, 1 second apart.