No description
- PHP 100%
|
|
||
|---|---|---|
| .github/workflows | ||
| debian | ||
| libs | ||
| src | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| composer.json | ||
| LICENSE | ||
| phpunit.xml | ||
| README.md | ||
Matomo/Decompress
Component providing several adapters to decompress files.
It supports the following compression formats:
- Zip
- Gzip
- Bzip
- Tar (gzip or bzip)
With the following adapters:
PclZip, based on the PclZip libraryZipArchive, based on PHP's Zip extensionGzip, based on PHP's native Gzip functionsBzip, based on PHP's native Bzip functionsTar, based on the Archive_Tar library from PEAR
Installation
With Composer:
{
"require": {
"matomo/decompress": "^2.1"
}
}
Usage
All adapters have the same API as they implement Matomo\Decompress\DecompressInterface:
// Extracting Gzip file
$extractor = new \Matomo\Decompress\Gzip('file.gz');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
// Extracting Bzip file
$extractor = new \Matomo\Decompress\Bzip('file.bz');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
// Extracting Zip file with ZipArchive
$extractor = new \Matomo\Decompress\ZipArchive('file.zip');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
// Extracting Zip file with PclZip
$extractor = new \Matomo\Decompress\PclZip('file.zip');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
// Extracting .tar.bz2 file
$extractor = new \Matomo\Decompress\Tar('file.tar.bz2', 'bz2');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
// Extracting .tar.gz file
$extractor = new \Matomo\Decompress\Tar('file.tar.gz', 'gz');
$extractedFiles = $extractor->extract('some/directory');
if ($extractedFiles === 0) {
echo $extractor->errorInfo();
}
License
The Decompress component is released under the LGPL v3.0.