I'm running a REST stream from Firebase with Laravel.
$guzzle = new \GuzzleHttp\Client;
$url = FirebaseUrlWithAuthKey;
$headers = ['headers'=>['Accept' => 'text/event-stream'],'stream'=>true];
$response = $guzzle->request('GET', $url,$headers);
$body = $response->getBody();
while (!$body->eof())
{
$this->doSomethingWithData($body->read(8192));
}
Listening to a Firebase node requires us to download all the existing data before listening for changes.
This is problematic as we have a lot of data at the node we're listening to and it's taking EIGHT minutes to download the initial data set because the fread()
PHP function seems to only be able to chunk 8192B.
So my questions are:
- Is it possible to truncate the initial dataset before listening to the node?
- Can I chunk more than 8192B with the
fread()
function?
Thanks!