Check out the StreamedResponse:
$response = new StreamedResponse();
$response->setCallback(function () {
echo 'Hello World';
flush();
sleep(2);
echo 'Hello World';
flush();
});
$response->send();
Read more here: http://symfony.com/doc/current/components/http_foundation/introduction.html#streaming-a-response
While this method has its simplicity and usefulness in certain cases, it's not the best user experience in a webpage. The HTML page will only be fully loaded at the end of your script, which may cause visual annoyances and the lack of Javascript support, incomplete CSS rendering, etc...
If you're going for the best visual experience, you could load an empty page, and then make concurrent ajax calls that will do the processing. ie. each AJAX request will process 5 records and output them.
This way you can have a progress bar or some other animation going on the page...