XUtils

UnifiedArchive

A unified reader and writer of compressed archives.


Quick start

Install library

composer require wapmorgan/unified-archive
### Install new driver
```sh
#install missing drivers, for example pear/archive_tar
composer require pear/archive_tar
#check out driver functions
./vendor/bin/cam system:formats TarByPear

#if needed, install extensions, cli tools and php libraries
# Extraction
$archive = UnifiedArchive::open('archive.zip'); // archive.rar, archive.tar.bz2
if (disk_free_space($output_dir) < $archive->getOriginalSize()) {
    throw new \RuntimeException('No needed space available. Need ' . ($archive->getOriginalSize() - disk_free_space($output_dir)) . ' byte(s) more');
}
$extracted = $archive->extract($output_dir);
echo 'Number of extracted files' . $extracted.PHP_EOL;

# Archiving
UnifiedArchive::create([
    'README.md' => '/default/path/to/README.md',
    '' => '/folder/with/content/',
], 'archive.zip');

Articles

  • coming soon...