alchemy/zippy
Zippy is a PHP library to read, create, list, and extract archives using CLI tools or PHP extensions. Supports ZIP plus GNU/BSD tar formats (.tar, .tar.gz, .tar.bz2) via a simple API for opening, iterating members, extracting, and creating archives.
Strengths:
GNUtar, BSDtar, Zip, PHPZip) to abstract archive operations, making it extensible for future formats (e.g., RAR, 7z) without core changes.Process component for CLI-based operations (e.g., tar), ensuring cross-platform compatibility (Linux/Windows) and robust error handling.Gaps:
tar) block execution; no native support for background jobs (e.g., Laravel Queues).Laravel Stack Fit:
composer require alchemy/zippy).Storage facade (e.g., S3, local disks) via resource streams.ZippyJob::dispatch($archiveData)).Potential Conflicts:
mbstring (Laravel’s default) and optionally zip/tar extensions. May need runtime checks (e.g., extension_loaded('zip')).Process component, which is already in Laravel’s vendor tree (no additional dependencies).High:
GuzzleTeleporter) are deprecated in favor of generic teleporters. Risk of breaking changes if migrating from older versions.tar rely on system binaries (tar, zip). Risk of failures on headless environments (e.g., Docker, serverless) or misconfigured PATHs.Mitigation Strategies:
ZipArchive) as fallbacks for critical paths.tar/zip binaries are available in Docker/CI pipelines.ArchiveService).Use Case Criticality:
Environment Constraints:
tar, zip) guaranteed to be available?zip extension enabled? If not, will ZipArchive suffice?Scalability Needs:
memory_limit)? If so, chunked processing is needed.Maintenance Plan:
league/flysystem-archive-plugin, spatie/laravel-temporary-filesystem)?Security:
openssl) may be needed post-archive.Laravel Ecosystem:
AppServiceProvider:
$this->app->singleton('zippy', function () {
return \Alchemy\Zippy\Zippy::load();
});
Zippy facade for clean syntax:
use Facades\Zippy;
$archive = Zippy::create('backup.zip', ['app' => storage_path('app')]);
Storage facade to pass streams:
$stream = Storage::disk('s3')->readStream('large-file.zip');
$archive = Zippy::open($stream)->extract(storage_path('temp'));
Queue Integration:
class GenerateArchiveJob implements ShouldQueue
{
public function handle(Zippy $zippy) {
$zippy->create('large-archive.zip', ['data' => $this->data]);
}
}
Event Integration:
event(new ArchiveGenerated($archivePath));
Pilot Phase:
ZipArchive for pure PHP).Gradual Rollout:
shell_exec('tar -czf ...')) with Zippy.exec() or system().Fallback Strategy:
class ArchiveService {
public function create(string $path, array $files): void {
if ($this->useZippy) {
Zippy::create($path, $files);
} else {
$zip = new ZipArchive();
$zip->open($path, ZipArchive::CREATE);
foreach ($files as $name => $source) {
$zip->addFromString($name, file_get_contents($source));
}
$zip->close();
}
}
}
PHP Versions: Tested on 7.1–8.1; validate with 8.2+ (e.g., named arguments, JIT).
Laravel Versions: Compatible with Laravel 7+ (Symfony 4+ components).
Dependencies:
mbstring, symfony/process (already in Laravel).guzzlehttp/guzzle (for remote resources), zip/tar extensions.Cross-Platform:
tar/zip CLI availability (e.g., Git Bash, WSL).tar, zip binaries are in PATH or use Alpine-based images with busybox alternatives.Phase 1: Core Integration
composer.json.Phase 2: Advanced Features
Storage for cloud archives.Phase 3: Optimization
Phase 4: Monitoring
Pros:
alchemy/zippy).Process, Filesystem).Cons:
How can I help you explore Laravel packages today?