markocupic/zip-bundle

提供一种简单的ZIP扩展,用于递归压缩目录。

安装数: 6,091

依赖者: 4

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 0

开放问题: 0

类型:contao-bundle

1.1.1 2022-12-27 17:54 UTC

This package is auto-updated.

Last update: 2024-09-27 22:01:31 UTC


README

Alt text

Zip扩展

本扩展提供了一个简单的Zip类。

使用方法

// 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');