Grandt / PHPZip

PHP Class to create archives of compressed files in ZIP format.
http://www.phpclasses.org/package/6110
118 stars 21 forks source link

Get a stream without printing it immediately #45

Open Rudloff opened 7 years ago

Rudloff commented 7 years ago

Hello,

I'm trying to get a Zip stream that I can manipulate. I can't use ZipStream because it prints the stream instead of returning it.

I tried to use Zip::getZipFile() but it seems to close the stream as soon as I return it:

function getZipStream()
{
    $zip = new \PHPZip\Zip\File\Zip();
    $zip->addFile('foo', 'foo');
    $stream = $zip->getZipFile();
    var_dump(is_resource($stream)); //bool(true)
    return $stream;
}

var_dump(is_resource(getZipStream())); //bool(false)