I am using Lumen for a set of APIs.
using streamedresponse built in library of symphony.
use Symfony\Component\HttpFoundation\StreamedResponse;
protected function getFileResponseHeaders($filename)
{
return [
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Content-type' => 'text/csv; =utf-8',
'charset' => 'utf-8',
'Content-Disposition' => 'attachment; filename='.$filename,
'Expires' => '0',
'Pragma' => 'public'
];
}
//'Content-Type: '
protected function streamFile($callback, $headers)
{
$response = new StreamedResponse($callback, 200, $headers);
$response->send();
}
I am using this approach in a scenario where I want to stream data in command line with chunks of 2000. I have bulk of data upto 7 millions rows to stream.
This whole thing is working completly fine on a server with following specs.
But I have other servers where this stream only list down first batch. Specs of other servers are identical as following:
I want guidance to run this stream on all the servers. I have compared php.ini and every other thing that I can think of. Thanks in advance.
PHP ZTS was missing from all the servers except the one where the streamed response was working.
Adding php zts
on the server fixed the problem for me finally.