PHP code example of nemo64 / zip-stream
1. Go to this page and download the library: Download nemo64/zip-stream library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nemo64 / zip-stream example snippets
use function GuzzleHttp\Psr7\stream_for;
use function GuzzleHttp\Psr7\try_fopen;
use Narrowspark\HttpEmitter\SapiStreamEmitter;
use Nemo64\ZipStream\ZipResponse;
use Nemo64\ZipStream\ZipStream;
$zip = new ZipStream();
$zip->add('file1.jpg', stream_for(try_fopen('file1.jpg', 'r')));
// be sure that before you send this response that there is no output buffering engaged.
while (@ob_end_clean()) {}
$response = ZipResponse::create($zip, 'my_archive.zip');
$emitter = new SapiStreamEmitter();
$emitter->emit($response);