To create a zip archive in Laravel, you can use the Zipper class from the chumper/zipper package. This package provides an easy-to-use interface for creating zip archives in PHP.
To use the Zipper class, you’ll need to install the chumper/zipper package using Composer. You can do this by running the following command:
composer require chumper/zipper
Once the package is installed, you can use the Zipper class to create a zip archive like this:
use Chumper\Zipper\Zipper;
$zipper = new Zipper;
$zipper->make('path/to/archive.zip')->add('path/to/file1.txt')->add('path/to/file2.txt');
$zipper->close();
This will create a zip archive called archive.zip that contains the file1.txt and file2.txt files.
You can also use the folder method to add an entire directory to the zip archive:
use Chumper\Zipper\Zipper;
$zipper = new Zipper;
$zipper->make('path/to/archive.zip')->folder('folder')->add('path/to/file1.txt')->add('path/to/file2.txt');
$zipper->close();
This will create a zip archive that contains a folder directory with the file1.txt and file2.txt files inside it.
