wapmorgan / Unifiedarchive
Projects that are alternatives of or similar to Unifiedarchive
UnifiedArchive - an archive manager with a unified way for different formats. Supports all basic (listing, reading, extracting and creation) and specific features (compression level, password-protection). Bundled with console program for working with archives.
Supported formats (depends on installed drivers): zip, 7z, rar, one-file(gz, bz2, xz), tar (tar.gz, tar.bz2, tar.x, tar.Z), and a lot of others.
Goal
If on your site/service there is a possibility of usage archives of many types, and you would like to work with them unified, you can use this library.
UnifiedArchive can utilize to handle as many formats as possible:
- ZipArchive, RarArchive, PharData
- Pear/Tar
- 7zip cli program via Gemorroj/Archive7z
- zip, tar cli programs via Alchemy/Zippy
- ext-zlib, ext-bz2, ext-xz
Functions & Features
- Opening an archive with automatic format detection
- Opening archives encrypted with password (zip, rar, 7z)
- Getting information about uncompressed size of archive contents
- Listing archive content
- Getting details ([un]compressed size, date of modification) of every archived file
- Reading archived file content as stream (zip, rar, gz, bz2, xz)
- Extracting archived file content as is or on a disk
- Appending an archive with new files
- Removing files from archive
- Creating new archives with files/directories, adjust compression level (zip, gzip), set passwords (7z, zip)
Quick start
composer require wapmorgan/unified-archive
# install libraries for support: tar.gz, tar.bz2, zip
composer require pear/archive_tar alchemy/zippy
# or if you can, install p7zip package in your OS and SevenZip driver for support a lot of formats (tar.*, zip, rar)
composer require gemorroj/archive7z
# to work with rar natively
pecl install rar
More information about formats support in formats page.
Use it in code:
$archive = \wapmorgan\UnifiedArchive\UnifiedArchive::open('archive.zip'); // archive.rar, archive.tar.bz2
$extracted_size = $archive->countUncompressedFilesSize();
$files_list = $archive->getFileNames();
echo 'Files list: '.array_map(function ($file) { return '- '.$file."\n"; }, $files_list).PHP_EOL;
echo 'Total size after extraction: '.$extracted_size.' byte(s)';
Built-in console archive manager
UnifiedArchive is distributed with a unified console program to manipulate archives. It supports all formats that UnifiedArchive does and can be used to manipulate archives without other software. To show help, launch it:
./vendor/bin/cam --help