Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Flysystem Ziparchive

Flysystem Ziparchive Laravel Package

league/flysystem-ziparchive

Flysystem ZipArchive adapter sub-split. Use it to work with ZIP files via Flysystem’s filesystem abstraction. This repo is read-only for packaging; file issues and pull requests on the main Flysystem project: https://github.com/thephpleague/flysystem

View on GitHub
Deep Wiki
Context7

Flysystem Adapter for ZipArchive's

Frequently asked questions about Flysystem Ziparchive
How do I install league/flysystem-ziparchive in a Laravel project?
Run `composer require league/flysystem-ziparchive` to install the package. No additional Laravel-specific setup is required beyond configuring the adapter as a custom disk in `config/filesystems.php`. The package leverages Flysystem’s existing integration with Laravel’s Storage facade.
What Laravel versions does this package support?
This adapter works with Laravel 8+ and requires Flysystem v3+, which is compatible with modern Laravel releases. Ensure your project uses PHP 7.4+ for ZipArchive support, as the adapter relies on PHP’s native extension.
Can I use this for large ZIP files (e.g., >100MB)?
ZipArchive processes files in-memory, so large ZIPs may hit PHP memory limits or slow down. For files exceeding 50MB, consider alternatives like `mikehaertl/php-archive` or chunked streaming solutions. Test memory usage with `memory_get_usage()` in your workflows.
How do I configure a custom ZIP disk in Laravel?
Add a new disk entry in `config/filesystems.php` under the `disks` array. Example: `'zip_archive' => ['driver' => 'ziparchive', 'path' => storage_path('app/archives')]`. Then use it via `Storage::disk('zip_archive')->put('file.zip', ...)` in your code.
Is this adapter thread-safe for concurrent writes?
No, ZipArchive is not thread-safe. Avoid concurrent writes to the same ZIP file. For high-traffic applications, implement locking (e.g., file locks or database semaphores) or offload ZIP generation to queue workers using Laravel Queues.
How can I validate ZIP file integrity after creation?
Use Flysystem’s built-in checksum methods (e.g., `Storage::disk('zip_archive')->hash('file.zip')`) or implement custom validation with `ZipArchive::status()` to check for corruption. For critical workflows, consider checksumming files before adding them to the ZIP.
Can I combine this adapter with other Flysystem drivers (e.g., S3)?
Yes, this adapter integrates seamlessly with other Flysystem drivers. For example, you can stream files from S3 into a ZIP using `Storage::disk('s3')->get()` and then write them to a ZIP disk. Hybrid workflows like this are fully supported.
What are the performance implications of using ZipArchive?
ZipArchive is CPU-intensive, especially for large files or many operations. For performance-critical applications, benchmark your workflows and consider async processing (e.g., Laravel Queues) or lighter alternatives like `ZipStream` for streaming ZIPs.
How do I handle file path collisions in ZIP archives?
Flysystem normalizes paths, but ZIP archives enforce strict naming. Use unique filenames (e.g., UUIDs) or implement custom logic in your `put()` calls to resolve collisions. Example: `Storage::disk('zip_archive')->put('unique_'.Str::uuid().'.zip', ...).
Are there alternatives to league/flysystem-ziparchive for Laravel?
Yes, alternatives include `mikehaertl/php-archive` (for streaming ZIPs) or `spatie/laravel-medialibrary` (for media packaging). However, this adapter is ideal if you need Flysystem’s abstraction for ZIPs, especially when integrating with Laravel’s Storage facade or existing Flysystem workflows.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views