PHP code example of cosmin-ciolacu / zipper

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

    

cosmin-ciolacu / zipper example snippets


use CosminCiolacu\Zipper\Zipper;

// create zip with files
$zipPath = 'path/to/zip.zip';
$files = ['path/to/file1.txt', 'path/to/file2.txt'];

Zipper::createZip($zipPath, $files);

// unzip
$unzipPath = 'path/to/unzip';
Zipper::unzip($zipPath, $unzipPath);

use CosminCiolacu\Zipper\Exceptions\FailedToOpenZipFileException;

try {
    Zipper::unzip('path/to/zip.zip', 'path/to/unzip');
} catch (FailedToOpenZipFileException $e) {
    echo $e->getMessage();
}