vsolution-dev/laravel-zipper

This package's canonical repository appears to be gone and the package has been frozen as a result.

0.0.2 2024-05-20 13:01 UTC

This package is auto-updated.

Last update: 2024-06-20 13:08:19 UTC


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.