exeque / laravel-zipstream
Zip streaming for Laravel
Requires
- php: ^8.4
- maennchen/zipstream-php: ^3.2
Requires (Dev)
- laravel/pint: ^1.21
- league/flysystem-aws-s3-v3: ^3.35
- orchestra/testbench: ^10.9
- pestphp/pest: ^3.8|^4.0
- symfony/var-dumper: ^7.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel ZipStream
A fluent Laravel wrapper for maennchen/zipstream-php to easily generate and stream ZIP archives.
Installation
composer require exeque/laravel-zipstream
The service provider registers itself. Upgrading from 0.x? See the upgrade guide.
Both of these are optional - the package works with its own defaults:
# Defaults for compression, progress reporting and size formatting php artisan vendor:publish --tag="laravel-zipstream-config" # The progress strings, shipped in 30 languages php artisan vendor:publish --tag="laravel-zipstream-translations"
See Configuration for what each key does.
Basic Usage
use ExeQue\ZipStream\Facades\Zip; // Stream an archive to the browser return Zip::as('gallery.zip') ->fromDisk('s3', 'events/2026/photo.jpg') ->fromLocalDirectory('/var/exports/2026', 'exports') ->fromRaw('README.txt', 'Thanks for downloading!') ->toResponse(); // Or build it straight to a disk, while it uploads Zip::fromDiskDirectory('s3', 'events/2026', 'gala') ->saveToDisk('s3', 'archives/gala.zip');
Nothing is buffered: an archive of any size streams at constant memory, whether it goes to the browser, a disk or a local path.
Documentation
Documentation: Here
Upgrading from 0.x? See the upgrade guide.
Testing
composer test
The S3 test for saveToDisk() is skipped unless an S3-compatible server is available. See
Testing against S3 with MinIO to run it locally.
License
The MIT License (MIT). Please see License File for more information.
