<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

$startedAt = time();
$value = 0;
$id = uniqid();

while ( $value < 100 && (time() - $startedAt) < 20) {

	echo "event: progressBar\n";
	echo "data: $value\n\n";
	ob_end_flush();
	flush();
	
	$value += mt_rand(1, 1000)/500.0;
	usleep(1e5);
}

echo "event: progressBar\n";
echo "data: 100\n\n";
ob_end_flush();
flush();
sleep(1);
?>