:floppy_disk: PHP ZIP Streaming Library
The main
branch is not stable. Please see the
releases for a stable
version.
A fast and simple streaming zip file downloader for PHP. Using this library will
save you from having to write the Zip to disk. You can directly send it to the
user, which is much faster. It can work with S3 buckets or any PSR7 Stream.
Please see the LICENSE file for licensing and warranty information.
Simply add a dependency on maennchen/zipstream-php to your project’s
composer.json
file if you use Composer to manage the dependencies of your
project. Use following command to add the package to your project’s dependencies:
composer require maennchen/zipstream-php
For detailed instructions, please check the
Documentation.
// Autoload the dependencies
require 'vendor/autoload.php';
// create a new zipstream object
$zip = new ZipStream\ZipStream(
outputName: 'example.zip',
// enable output of HTTP headers
sendHttpHeaders: true,
);
// create a file named 'hello.txt'
$zip->addFile(
fileName: 'hello.txt',
data: 'This is the contents of hello.txt',
);
// add a file named 'some_image.jpg' from a local file 'path/to/image.jpg'
$zip->addFileFromPath(
fileName: 'some_image.jpg',
path: 'path/to/image.jpg',
);
// finish the zip stream
$zip->finish();
8.1
ZipStream\Option\Method
has been replaced with the enumZipStream\CompressionMethod
.@internal
and should not be used from theZipStream\CompressionMethod
ZipStream\Exception*
ZipStream\ZipStream
ZipStream\Option\Archive
has been replaced in favor of namedZipStream\ZipStream
constuctor.largeFileSize
& largeFileMethod
has been removed. IfcompressionMethods
based on the file size, you’ll have tohttpHeaderCallback
changed the type from callable
toClosure
.zeroHeader
has been replaced with the optiondefaultEnableZeroHeader
and can be overridden for every file. Its defaultfalse
to true
.statFiles
was removed since the library no longer checksdeflateLevel
has been replaced with the optiondefaultDeflateLevel
and can be overridden for every file.name
) of the ZipStream\ZipStream
constuctor has beenoutputName
.outputName
is empty. If you do not want tosendHttpHeaders
to false
.ZipStream\Option\File
has been replaced in favor of namedZipStream\ZipStream->addFile*
functions.method
has been renamed to compressionMethod
.time
has been renamed to lastModificationDateTime
.size
has been renamed to maxSize
.https://github.com/maennchen/ZipStream-PHP/tree/2.0.0#upgrade-to-version-200
https://github.com/maennchen/ZipStream-PHP/tree/2.0.0#upgrade-to-version-100
ZipStream-PHP is a collaborative project. Please take a look at the
.github/CONTRIBUTING.md file.
Versions are supported according to the table below.
Please do not open any pull requests contradicting the current version support
status.
Careful: Always check the README
on main
for up-to-date information.
Version | New Features | Bugfixes | Security |
---|---|---|---|
3 | ✓ | ✓ | ✓ |
2 | ✗ | ✗ | ✓ |
1 | ✗ | ✗ | ✗ |
0 | ✗ | ✗ | ✗ |
This library aligns itself with the PHP core support. New features and bugfixes
will only target PHP versions according to their current status.
See: https://www.php.net/supported-versions.php