UnifiedArchive - an archive manager with a unified way of working with all popular archive formats (zip/7z/rar/gz/bz2/xz/cab/tar/tar.gz/tar.bz2/tar.x/tar.Z/...) for PHP with ability for listing, reading, extracting and creation + built-in console archive manager.

1.1.2 2021-03-01 00:37 UTC

This package is auto-updated.

Last update: 2021-03-11 22:20:09 UTC


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.

Latest Stable Version Total Downloads Daily Downloads License Latest Unstable Version

Tests & Quality: Build status Scrutinizer Code Quality Code Coverage


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


  1. Drivers and their formats.
  2. Usage with examples.
  3. Full API description.
  4. Changelog.