PHP code example of dimabdc / zipstream64

1. Go to this page and download the library: Download dimabdc/zipstream64 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/ */

    

dimabdc / zipstream64 example snippets


use brokencube\ZipStream\ZipStream;

# Autoload the dependencies
ip');

# create a file named 'hello.txt' 
$zip->addFile('hello.txt', 'This is the contents of hello.txt');

# add a file named 'image.jpg' from a local file 'path/to/image.jpg'
$zip->addFileFromPath('some_image.jpg', 'path/to/image.jpg');

# add a file named 'goodbye.txt' from an open stream resource
$fp = tmpfile();
fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
$zip->addFileFromStream('goodbye.txt', $fp);
fclose($fp);

# add a file named 'farewell.txt' from a PSR7 stream (e.g. Guzzle / AWS)
$amazonS3 = new Sdk()->createS3();
$file = $amazonS3->getObject(['Bucket' => 'bucket.name', 'Key' => 'path/to/farewell.txt']);
$zip->addFileFromPsr7Stream('farewell.txt', $file['Body']);

# finish the zip stream
$zip->finish();

$zip = new ZipStream('example.zip', [ZipStream::OPTION_USE_ZIP64 => false]);