Laravel 5 create and download zip/archive file using chumper/zipper composer package.

How to create zip file using Laravel `chumper/zipper` package. Let’s see how to create zip file or folder step by step. Let’s, first of all, install “chumper/zipper” package. So, Open command prompt and goto the root directory of the Laravel and fire below command.

composer require chumper/zipper

After installing the package open the app config file from “config/app.php” file then append below Provides and Aliases to app.php file.

'providers' => [
'aliases' => [
    'Zipper' => 'Chumper\Zipper\Zipper'

You can now access Zipper with the¬†Zipper¬†alias for creating the zip file. So let’s create the zip file of images existing on the public folder. Make sure you have the “images” folder inside of the public directory and Also make sure the “thecodingstuff” directory exists inside of the public directory. If not exists please create both directories.

Then used below code for creating the zip file of images.

public function downloadZip()
    $images = glob(public_path('images/*'));
    return response()->download(public_path('thecodingstuff/'));

If you face any issue after using above code written the comment below.