PHP code example of sergiodanilojr / zipper

1. Go to this page and download the library: Download sergiodanilojr/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/ */

    

sergiodanilojr / zipper example snippets



SergioDaniloJr\Zipper\Zipper;

$zipper = new Zipper();

$fileExample = __DIR__."/assets/files/example-file.txt";

$single = $zipper->zipFile($fileExample);

//It'll bring the way of the zip File
echo $single;


SergioDaniloJr\Zipper\Zipper;

$zipper = new Zipper();

$fileOne = __DIR__."/assets/files/example-file.txt";
$fileTwo = __DIR__."/assets/files/example-file-two.txt";

$files = [
    $fileOne,
    $fileTwo
];

//Here I'll set a new folder that not exists yet.
$path = __DIR__."/assets/files/ZipperFiles";

$several = $zipper->zipFiles($files, "MadeWithZipper", $path);

echo $several;



SergioDaniloJr\Zipper\Zipper;

$zipper = new Zipper();

$fileToExtract = __DIR__ . "/assets/files/MadeWithZipper.zip";

//Here I'll set a new folder that not exists yet. But You can set a existent folder.
$destiny = __DIR__ . "/assets/files/Storage";

$extracted = $zipper->extract($fileToExtract,$destiny);

echo $extracted;



SergioDaniloJr\Zipper\Zipper;

$zipper = new Zipper();

$fileExample = __DIR__ . "/assets/files/example-file.txt";

//This method don't return, obvly, a way!
$zipper->download($fileExample);



SergioDaniloJr\Zipper\Zipper;

$path = __DIR__."/ZipperFolder";

// Like that you can set a default folder for save the zip files generated with the methods above.
$zipper = new Zipper($path);

// NOTE: If you set a folder that not exist, Zipper understanding this and will create a new folder like you want! Zipper's Wonderful, no?!



SergioDaniloJr\Zipper\Zipper;

$zipper = new Zipper();

//When there'is an error, you can calll the message method for show the error message, it comes like a 'string' type

$zipper->message();