Today, We are going to learn Laravel create zip/archive file using chumper/zipper package. We can easily create a zip file and download it using chumper zipper package Laravel. We are going to create a ZIP file including folders or files step by step.

Laravel create zip/archive file using chumper/zipper

First of all, We are going to install chumper zipper package for creating a zip file. Let’s open your command prompt and go to the project directory then follow below command.

Once the package is installed we have to append the Provider and Aliases into the Laravel config file. Let’s open “config/app.php” config file then append Provider and Aliases like.

The chumper zipper package is ready for use. Now, We are going to create a zip file of images folder and download it using the route. Let’s write the sample code to create a zip file and download it.

First of all, I create the array of images exists on the images folder using PHP glob method. Then I called the Zipper::make method for creating a zip file. The first parameter is the folder name or file name where you want to create or stores zip with a name. Then I have to pass the images array to the add method.

After, creating the zip file we can easily download it using download method. If you face any issue during creating a zip file or download zip file please write the comment below.

Leave a Reply