Laravel 5 create and download zip file example using chumper/zipper composer packageBy Hardik Savani | May 10, 2016 | | 9302 Viewer | Category : Laravel
Share this post:
Sometimes, we need to create file of our project directory and give to download that zip file to users. we are always prefer zip file because it is very safe and secure from virus. If you want to generate zip file and donwload that file in your laravel 5 application then you do it easily using chumper/zipper composer package. In this post i give you example to create zip file and donwload from scratch. So first we have to follow bellow step for install package.
First fire following command on your terminal.
composer require chumper/zipper
After install this package, Now open config/app.php file and add service provider and aliase.
'providers' => [
'aliases' => [
'Zipper' => 'Chumper\Zipper\Zipper'
ok, now we are ready to use Zipper class globally. So now use can use how to create zip file and download it that write in your controller this way. i added controller function for doneload zip file so you can use anyway.
Make sure you have two folder in your public directory:
1.js(with some files)
2.mydir(store zip file here)
public function downloadZip()
$files = glob(public_path('js/*'));
Try this it will help you and for more information click here: Zipper.
Tags :chumper/zipper Download Example File Laravel Laravel 4 Laravel 5 Laravel 5.2 Package Scratch Zip
- How to implement Email Verification with Activation Code example from Scratch in Laravel 5.2 ?
- How to add Delete cascade to existing column in Laravel 5, without remove column?
- Laravel 5 dynamic autocomplete search using select2 JS Ajax - Part 1
- How to get current url with query string in codeigniter?
- Jquery ajax request example
- Laravel 5 Localization(trans helper) tutorial example
- AngularJS - How to Limit String Length using Filter?
- Ckeditor required field validation example in Jquery