The idea: show progress for process that is running in the background
Execution: takes advantage of the fact that JavaScript is loaded in parallel

ignore_user_abort();
set_time_limit(3600);
session_write_close();
@ob_end_clean();
@ob_end_flush();
@header('Content-Encoding: text/html');

echo 'I am doing some very very very long job <br/>';
$taskId = uniqueId();
touch($taskId);

echo '<script src="url to exectute task?taskId=' . $taskId . '"></script>';

echo 'Doing it ';
while (file_exists($taskId)) {
    echo '|';
    sleep(5);
}
echo '<br/>';

/**
 * Job done, do something else
 */

P.S. Dont forget to unlink the file when the background task is done

Simple as that.