vsolution-dev / laravel-zipper
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 1 835
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- illuminate/support: 5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0
README
Laravel Zipper Library
This library provides a convenient way to zip files in Laravel applications.
Installation
You can install this library using Composer. Run the following command:
composer require vsolution-dev/laravel-zipper
After the installation, you need to add the service provider and facade to your app.php
configuration file.
Add the following line to the providers
array:
VSolutionDev\LaravelZipper\ServiceProvider::class,
And add the following line to the aliases
array:
'Zipper' => VSolutionDev\LaravelZipper\Facades\Zipper::class,
Requirements
This library requires PHP 7.4 or above. Make sure your server meets this requirement before installing.
Usage
To use this library, you can follow the example below:
$files = collect(); Qrcode::query() ->lazyById(1000) ->each(function ($qrcode) use ($files) { $files->add([ 'url' => $qrcode->url, // http://www.example.com/qrcode.png 'name' => "{$qrcode->id}.png" ]); }); Zipper::queue($files, 'qrcodes.zip', 's3') ->allOnQueue('longtime') ->chain([ (new SendMail())->attachFromStorageDisk('qrcodes.zip', 's3') ]);
In this example, after queuing the files for zipping using Zipper::queue(), we chain it with the SendMail job. The SendMail job is responsible for sending an email with the zip file attached. It uses the attachFromStorageDisk() method to attach the zip file from the specified storage disk ('s3' in this case).
Make sure you have the SendMail job defined with the appropriate logic to send the email. You may need to customize it according to your email sending implementation.