I'm currently facing an issue with php and flush(). It was working fine last week, but not now.
I tried several methods, disable all buffering system I found (zlib, output_buffering) and still no solution.
I'm using Symfony 3.2.7 with PHP 5.6.26 (with Xampp on windows 7).
I followed the documentation on Symfony, no luck. I also tried several solutions on StackOverflow but no luck either.
The answer here doesn't solve the problem as output_buffering is set to off, so there is no buffer to flush with ob_flush()
I joined you the part of the code where the StreamedResponse is, in case the issue is just under my eyes.
$response = new StreamedResponse();
$response->setCallback(function (){
$directory = $this->container->getParameter("awstats.directory");
echo $this->render("StatBundle:Default:update.html.twig")->getContent();
flush();
foreach (scandir($directory) as $key => $file) {
if ( is_file( $directory . '\\' . $file ) )
{
$awf = new Awfile( $directory . '\\' . $file , $this->getDoctrine(), $this->container);
$awf->parseInit();
$awf->setStreamEnable(true);
$stats = $awf->saveLinks( $this->container->getParameter("awstats.regex") );
echo $this->render("StatBundle:Default:streamUpdateScript.html.twig")->getContent();
flush();
}
}
});
$response->sendHeaders();
$response->send();
So if you have any idea, I will be pleased to try it !