SteamedResponse not working in lumen on other server

115 Views Asked by At

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.

  • php 7.3.27
  • centos fedora 7
  • apache 2.4.41
  • mysql8

But I have other servers where this stream only list down first batch. Specs of other servers are identical as following:

  • php 7.4
  • centos 8
  • apache 2.4.47
  • mysql8

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.

1

There are 1 best solutions below

0
Shahid Rafiq On BEST ANSWER

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.