PHP code example of aungmyokyaw / zipper

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

    

aungmyokyaw / zipper example snippets


$files = glob('public/files/*');
Zipper::make('public/test.zip')->add($files)->close();

$zipper = new \Amk\Zipper\Zipper;

$zipper->make('test.zip')->folder('test')->add('composer.json');
$zipper->zip('test.zip')->folder('test')->add('composer.json','test');

$zipper->remove('composer.lock');

$zipper->folder('mySuperPackage')->add(
    array(
        'vendor',
        'composer.json'
    ),
);

$zipper->getFileContent('mySuperPackage/composer.json');

$zipper->make('test.zip')->extractTo('',array('mySuperPackage/composer.json'),Zipper::WHITELIST);

$zipper->close();

Zipper::make('test.zip')->folder('test')->add('composer.json');
Zipper::make('test.zip')->folder('test')->remove('composer.json');

$logFiles = Zipper::make('test.zip')->listFiles('/\.log$/i'); 
$notLogFiles = Zipper::make('test.zip')->listFiles('/^(?!.*\.log).*$/i'); 

Zipper::make('test.zip')->folder('test')->extractTo('foo');

Zipper::make('test.zip')->extractTo('public', array('vendor'), Zipper::WHITELIST);

Zipper::make('test.zip')->extractTo('public', array('vendor'), Zipper::BLACKLIST);

Zipper::make('test.zip')
    ->folder('vendor')
    ->extractTo('public', array('composer', 'bin/phpunit'), Zipper::WHITELIST | Zipper::EXACT_MATCH);

Zipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/\.php$/i'); 

Zipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/^(?!.*test\.php).*$/i');