markocupic / zip-bundle
Provides a simple ZIP extension for zipping directories recursively.
Installs: 6 490
Dependents: 4
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Type:contao-bundle
Requires
- php: ^7.4 || ^8.0
- ext-zip: *
- contao/core-bundle: ^4.13 || ^5.0
Requires (Dev)
- contao/easy-coding-standard: ^5.0
- contao/manager-plugin: ^2.3.1
- contao/test-case: ^4.6
- phpunit/phpunit: ^9.3
- symfony/phpunit-bridge: ^5.4
README
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');