ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.

Fund package maintenance!
Open Collective

Installs: 125 134 666

Dependents: 104

Suggesters: 1

Security: 0

Stars: 1 612

Watchers: 22

Forks: 132

Open Issues: 3

3.1.0 2023-06-21 14:59 UTC


Main Branch Coverage Status Latest Stable Version Total Downloads Financial Contributors on Open Collective License

Unstable Branch

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: '',

    // enable output of HTTP headers
    sendHttpHeaders: true,

// create a file named 'hello.txt'
    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'
    fileName: 'some_image.jpg',
    path: 'path/to/image.jpg',

// finish the zip stream

Upgrade to version 3.0.0


  • Minimum PHP Version: 8.1
  • Only 64bit Architecture is supported.
  • The class ZipStream\Option\Method has been replaced with the enum ZipStream\CompressionMethod.
  • Most clases have been flagged as @internal and should not be used from the outside. If you're using internal resources to extend this library, please open an issue so that a clean interface can be added & published. The externally available classes & enums are:
    • ZipStream\CompressionMethod
    • ZipStream\Exception*
    • ZipStream\ZipStream

Archive Options

  • The class ZipStream\Option\Archive has been replaced in favor of named arguments in the ZipStream\ZipStream constuctor.
  • The archive options largeFileSize & largeFileMethod has been removed. If you want different compressionMethods based on the file size, you'll have to implement this yourself.
  • The archive option httpHeaderCallback changed the type from callable to Closure.
  • The archive option zeroHeader has been replaced with the option defaultEnableZeroHeader and can be overridden for every file. Its default value changed from false to true.
  • The archive option statFiles was removed since the library no longer checks filesizes this way.
  • The archive option deflateLevel has been replaced with the option defaultDeflateLevel and can be overridden for every file.
  • The first argument (name) of the ZipStream\ZipStream constuctor has been replaced with the named argument outputName.
  • Headers are now also sent if the outputName is empty. If you do not want to automatically send http headers, set sendHttpHeaders to false.

File Options

  • The class ZipStream\Option\File has been replaced in favor of named arguments in the ZipStream\ZipStream->addFile* functions.
  • The file option method has been renamed to compressionMethod.
  • The file option time has been renamed to lastModificationDateTime.
  • The file option size has been renamed to maxSize.

Upgrade to version 2.0.0

Upgrade to version 1.0.0


ZipStream-PHP is a collaborative project. Please take a look at the .github/ file.

Version Support

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

This library aligns itself with the PHP core support. New features and bugfixes will only target PHP versions according to their current status.


About the Authors


Code Contributors

This project exists thanks to all the people who contribute. [Contribute]. 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]




Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f7a697073747265616d2f6f7267616e697a6174696f6e2f392f6176617461722e737667