Laravel Create and Download Zip File using chumper/zipper

Today now in this post i will talk about Laravel Create and Download Zip File by using chumper/zipper. Sometimes, you need to create the file of our project directory and give to the download that zip file to users. we are always choice zip file because it is a very safe and also very secure from virus. If we want to generate the zip file and need download that file in our laravel application then we can do it very easily by using chumper/zipper composer package.

So now in this post i will give you a very good example to create the zip file and download from the scratch. So at first we need to follow the bellow step for install the package.

At first nneed to fire following the command on our terminal.

Installation Package
composer require chumper/zipper

So after the install this package, Now need to open config/app.php file and add the service provider and aliase.


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

okay, now here we are ready to use the Zipper class globally. So now we use can use how to create zip the file and download it that write in our controller on this way.Here i will added controller function for download zip file so we can use anyway.

So make sure we have two folder in our public directory:

1.js(with some files)

2.mydir(store zip file here)

Controller Method

public function downloadZip()
    $files = glob(public_path('js/*'));

    return response()->download(public_path('mydir/'));

So try this it will help you and for the more information click here: Zipper.

Read Also: Generate Captcha code and Validation by using BotDetect package in laravel

Thanks for read. I hope it help you. For more you can follow us on facebook

Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.