Repository navigation
1.0.0
Everything streams. An archive of any size is built while it is written, at constant memory, whether it goes to
a browser, a Laravel disk or a local path.
Upgrading from 0.x? Start with the upgrade guide. Every breaking change is there with before and after.
The fix this release started as
saveToDisk() built the whole archive into php://temp before writing a byte, so peak local disk - or memory,
when the temp directory was not writable - equalled the archive size. A 129 MB archive exhausted a default
128 MB memory_limit.
ZipStream pushes while Flysystem and the AWS SDK pull. The archive is now produced inside a Fiber that the
reader drives, so only one chunk is ever held. A failed write leaves nothing behind: the S3 multipart upload is
aborted, the key removed only if this call created it, and the original exception rethrown.
What else is new
- Events are objects. A handler declares what it listens for by type-hinting its first parameter, and every
event carries a frozenContextwith the archive id, the entry being streamed and how far along it is. - Progress reports itself, throttled by bytes or by an interval, and renders as
"10 of 125 files"or
"5.00 KB of 64.00 MB"in thirty European languages. abort()stops an archive from a handler;abort(discard: true)throws it away, upload and all.fromDiskDirectory()andfromLocalDirectory()add a whole prefix from one listing, sizes included.Zip::fake()records what an archive would have contained, so composition is testable without storage.- The response owns PHP's output layer - zlib, buffers, encoding, time limit - so a large download streams
rather than stalls. ArchiveBuilderdeclares the public surface, with tests that fail on anything public it does not cover.
Breaking changes
output(bool)split intotoString()andtoStream(); the stream is read-once and not seekableEventTypegone;$event->idis$event->context->id, and the event interfaces moved toEvents\ContractszeroHeader(?bool)replaced bywithZeroHeader(),withoutZeroHeader()andinheritZeroHeader()Content-Typeisapplication/zip, and a plain filename is no longer quotedsaveToDisk()takes$options, andDiskFile::make()takes aFilesystemAdapter- A failed write cleans up after itself, which includes deleting a path this call created
- Three new config keys:
progress_every,size_precision,manage_output
Documentation
exeque.github.io/laravel-zipstream - including driver pages for
S3 as both source and destination.