markocupic/zip-bundle

Provides a simple ZIP extension for zipping directories recursively.

Installs: 5 107

Dependents: 4

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 0

Open Issues: 0

Type:contao-bundle

1.1.1 2022-12-27 17:54 UTC

This package is auto-updated.

Last update: 2024-03-27 20:56:29 UTC


README

Alt text

Zip extension

This bundle provides a simple Zip class.

Usage

// Add dir recursive with unlimited depth, add dot files and folders too and store it to a given zip-file
$zip = (new \Markocupic\ZipBundle\Zip\Zip())
    ->ignoreDotFiles(false)
    ->stripSourcePath('path/to/source/dir')
    ->addDirRecursive('path/to/source/dir')
    ->run('path/to/destination/dir/myZip.zip');

// Add dir recursive depth: 1, collect only files and ignore empty folders
$zip = (new \Markocupic\ZipBundle\Zip\Zip())
    ->stripSourcePath('path/to/source/dir')
    ->addDirRecursive('path/to/source/dir', 1, true)
    ->run('path/to/destination/dir/myZip.zip');

// Add a file
$zip = (new \Markocupic\ZipBundle\Zip\Zip())
    ->stripSourcePath('path/to/source/dir')
    ->addFile('path/to/source/dir/myFile.txt')
    ->run('path/to/destination/dir/myZip.zip');

// Add files from a directory
$zip = (new \Markocupic\ZipBundle\Zip\Zip())
    ->stripSourcePath('path/to/source/dir')
    ->addDir('path/to/source/dir')
    ->run('path/to/destination/dir/myZip.zip');

// Add files from a directory
$zip = (new \Markocupic\ZipBundle\Zip\Zip())
   ->stripSourcePath('path')
   ->addDir('path/to/source/dir')
   ->addDir('path/toAnotherDir/source/dir')
   ->run('path/to/destination/dir/myZip.zip');