Arf, iāv been quietly forgotting my PHP skills for a while now
I think you may have to write something similar to :
// open a file for writing (or a target stream)
$destStream = fopen($filename, "w");
// get body as a stream
$body = $response->getBody();
// Copy-ing the body to the destination file
while (!$body->eof()) {
$part = $body->read(4096);
$readBytes = strlen($part);
fwrite($destStream, $part, $readBytes);
}
// Close the target file
fclose($destStream)