PHP code example of spm / zipper
1. Go to this page and download the library: Download spm/zipper library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spm / zipper example snippets
# Providers to add
Spm\Zipper\ZipperServiceProvider:class
#Facade to add
'Zipper' => Spm\Zipper\Facades\Zipper::class
# Set the path and name of the new zip file
$zip_file_name = public_path() . '\exports\file_name.zip';
Zipper::setFileName($zip_file_name)
# Add all folders to zip file
# They can be in different locations as long as they are indicated in the array
$folders_to_zip = [
public_path() . '\storage\general',
public_path() . '\storage\home',
];
Zipper::setFoldersToZip($folders_to_zip)
# Make the zip file
Zipper::makeZip();
# Set path to the zip file to unzip
$path_to_zipFile = $request->file('excel-file')->path();
Zipper::setPathToZipFile($path_to_zipFile)
# Set path to the unzipped file result
$path_to_unZip = public_path('storage\import');
Zipper::setPathToUnzip($path_to_unZip)
# Make de unzip file
Zipper::unZipFile()