wapmorgan/unified-archive
UnifiedArchive - an archive manager with unified interface 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.3.1
1.8M downloads/mo
#3775 most downloaded on Packagist
wapmorgan/UnifiedArchive
What this package is like to depend on
Last release 12 months ago
25 Aug 2025
Ships unpredictably
gaps range from 2 weeks to 2.0 years
Nearly every release is documented
notes for 33 of 33 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
34 releases · first in 2014
0 releases in the last 12 months
see the full history below
Release timeline
34 releases · May 2014 to Aug 2025Releases
latest 34-
1.3.125 Aug 2025 -
1.3.029 Jul 2025Release notes
Open source →Release for php 8.4 without deprecated-issues (#47 by @cedric-anne, #51)
-
1.2.127 Jun 2025Release notes
Open source →- Fixed bugs in:
- Enhancements:
- Improved performance in one-file drivers extraction (gzip - #49, bzip - #50 by @iasjennen)
- Docs:
- Specified supported php versions: 5.5.0-8.3.x, deprecations in 8.4.x (#47 by @cedric-anne)
- Fixed support status for
xzin matrix: SevenZip does not support it (#45 by @rotdrop)
Release notes
Open source →- Fixed bugs in:
- AlchemyZippy::getLastModifiedDate (#44 by @rotdrop)
- LzwStreamWrapper (#46 by @cod3beat)
- Enhancements:
- Improved performance in one-file drivers extraction (gzip - #49, bzip - #50 by @iasjennen)
- Docs:
- Specified supported php versions: 5.5.0-8.3.x, deprecations in 8.4.x (#47 by @cedric-anne)
- Fixed support status for
xzin matrix: SevenZip does not support it (#45 by @rotdrop)
-
1.2.030 Jun 2023Release notes
Open source →- Deprecate few functions:
- Formats::checkFormatSupportAbility() marked deprecated, use
can()instead. - UnifiedArchive: addFile() and addDirectory() marked deprecated, use
add()instead.
- Formats::checkFormatSupportAbility() marked deprecated, use
- Changed behaviour:
- UnifiedArchive: add() and create() changed
fileOrFileshandling: if passed string, then file/directory will be archived with full its original name (as opposed to relative name before). - Formats: detectArchiveFormat() and getFormatMimeType() returns null instead of false in case of failed type detection.
- UnifiedArchive::getMimeType() returns null instead of false.
- UnifiedArchive: add() and create() changed
- New:
- Improved
test()functionality - returns list of mismatched hashes.
- Improved
Release notes
Open source →- Deprecate few functions:
- Formats::checkFormatSupportAbility() marked deprecated, use
can()instead. - UnifiedArchive: addFile() and addDirectory() marked deprecated, use
add()instead.
- Formats::checkFormatSupportAbility() marked deprecated, use
- Changed behaviour:
- UnifiedArchive: add() and create() changed
fileOrFileshandling: if passed string, then file/directory will be archived with full its original name (as opposed to relative name before). - Formats: detectArchiveFormat() and getFormatMimeType() returns null instead of false in case of failed type detection.
- UnifiedArchive::getMimeType() returns null instead of false.
- UnifiedArchive: add() and create() changed
- New:
- Improved
test()functionality - returns list of mismatched hashes.
- Improved
- Deprecate few functions:
-
1.1.1017 Jan 2023 -
1.1.917 Jan 2023 -
1.1.820 Nov 2022Release notes
Open source →Fixed:
- Fixed opening an archive with password (#37)
- Fixed
UnifiedArchive->getComment()now returns null when comment is not supported by driver (#39) - Fixed
UnifiedArchive->getFileData()->modificationTimeis integer timestamp now in case of NelexaZip driver instead of DateTimeImmutable (#38) - Fixed
PharData::createfor zip-archives
Deprecations:
- Renamed methods of
UnifiedArchive:getFileNames=>getFilesextractFiles=>extractaddFiles=>adddeleteFiles=>deletearchiveFiles=>archivecanOpenArchive=>canOpen- Old methods are marked as deprecated and will be deleted in future releases.
- Marked as deprecated:
UnifiedArchive::detectArchiveType- useFormats::detectArchiveFormatinsteadUnifiedArchive::archiveDirectory/archiveFile- useUnifiedArchive::archiveinsteadUnifiedArchive::canCreateType-Formats::canCreate
New functions:
- Added method to get file extension for format:
Formats::getFormatExtension($archiveFormat) - Added method to get info about ready to archive files:
UnifiedArchive->prepareForArchiving($fileOrFiles, $archiveName = null) - Added method to create archive in memory:
UnifiedArchive::createInString()andBasicDriver::CREATE_IN_STRINGability constant - Added new pure driver for Zip/Tar(gz/bz2) - SplitbrainPhpArchive.
Release notes
Open source →Fixed:
- Fixed opening an archive with password (#37)
- Fixed
UnifiedArchive->getComment()now returns null when comment is not supported by driver (#39) - Fixed
UnifiedArchive->getFileData()->modificationTimeis integer timestamp now in case of NelexaZip driver instead of DateTimeImmutable (#38) - Fixed
PharData::createfor zip-archives
Deprecations:
- Renamed methods of
UnifiedArchive:getFileNames=>getFilesextractFiles=>extractaddFiles=>adddeleteFiles=>deletearchiveFiles=>archivecanOpenArchive=>canOpen- Old methods are marked as deprecated and will be deleted in future releases.
- Marked as deprecated:
UnifiedArchive::detectArchiveType- useFormats::detectArchiveFormatinsteadUnifiedArchive::archiveDirectory/archiveFile- useUnifiedArchive::archiveinsteadUnifiedArchive::canCreateType-Formats::canCreate
New functions:
- Added method to get file extension for format:
Formats::getFormatExtension($archiveFormat) - Added method to get info about ready to archive files:
UnifiedArchive->prepareForArchiving($fileOrFiles, $archiveName = null) - Added method to create archive in memory:
UnifiedArchive::createInString()andBasicDriver::CREATE_IN_STRINGability constant - Added new pure driver for Zip/Tar(gz/bz2) - SplitbrainPhpArchive.
-
1.1.730 Jul 2022Release notes
Open source →opendoes not throw an Exception, it returns null- returned deleted methods in UnifiedArchive:
canOpenArchive,canOpenType,canCreateType,getArchiveType,detectArchiveType,getFileResource,getArchiveFormat,isFileExists,getArchiveSize,countCompressedFilesSize,countUncompressedFilesSize.
Release notes
Open source →opendoes not throw an Exception, it returns null- returned deleted methods in UnifiedArchive:
canOpenArchive,canOpenType,canCreateType,getArchiveType,detectArchiveType,getFileResource,getArchiveFormat,isFileExists,getArchiveSize,countCompressedFilesSize,countUncompressedFilesSize.
-
1.1.630 Jul 2022Release notes
Open source →BC-breaking changes:
-
Changed signature:
UnifiedArchive::open($filename, string|null $password = null)=>UnifiedArchive::open($filename, array $abilities = [], string|null $password = null). Right now if second argument is string, it will be treated as password (for BC-compatability). -
openthrows an Exception when format is not recognized or there's no driver that support requested abilities. -
addFiles/deleteFiles/getComment/setCommentthrows an Exception when driver does not support this ability. -
Deleted methods in UnifiedArchive:
canOpenArchive,canOpenType,canCreateType,getArchiveType,detectArchiveType,getFileResource,getArchiveFormat,isFileExists,getArchiveSize,countCompressedFilesSize,countUncompressedFilesSize.
New features:
- Added passing needed abilities to UnifiedArchive::open() to select a better driver:
use \wapmorgan\UnifiedArchive\Drivers\BasicDriver; # opens an array with driver, that supports content streaming and appending $archive = \wapmorgan\UnifiedArchive\UnifiedArchive::open('archive.7z', [BasicDriver::STREAM_CONTENT, BasicDriver::APPEND]); # if not specified, uses OPEN or OPEN_ENCRYPTED check, if password passed
- Added
UnifiedArchive::test($files = [])(andcam files:testcommand) to test archive contents (compare actual control sum with stored crc32). - More informative output in commands:
system:drivers,system:formats,system:format, added commandfiles:test. - Added driver abilities to select better driver.
Driver changes:
- Added
NelexaZippure-PHP driver. - Added
Isodriver extraction ability. - Added commenting-ability for
SevenZipdriver (viadescript.ionfile in archive).
Release notes
Open source →BC-breaking changes:
- Changed signature:
UnifiedArchive::open($filename, string|null $password = null)=>UnifiedArchive::open($filename, array $abilities = [], string|null $password = null). Right now if second argument is string, it will be treated as password (for BC-compatability). openthrows an Exception when format is not recognized or there's no driver that support requested abilities.addFiles/deleteFiles/getComment/setCommentthrows an Exception when driver does not support this ability.- Deleted methods in UnifiedArchive:
canOpenArchive,canOpenType,canCreateType,getArchiveType,detectArchiveType,getFileResource,getArchiveFormat,isFileExists,getArchiveSize,countCompressedFilesSize,countUncompressedFilesSize.
New features:
- Added passing needed abilities to UnifiedArchive::open() to select a better driver:
use wapmorgan\UnifiedArchive\Abilities;use wapmorgan\UnifiedArchive\Drivers\Basic\BasicDriver; # opens an array with driver, that supports content streaming and appending $archive = \wapmorgan\UnifiedArchive\UnifiedArchive::open('archive.7z', [Abilities::STREAM_CONTENT, Abilities::APPEND]); # if not specified, uses OPEN or OPEN_ENCRYPTED check, if password passed - Added
UnifiedArchive::test($files = [])(andcam files:testcommand) to test archive contents (compare actual control sum with stored crc32). - More informative output in commands:
system:drivers,system:formats,system:format, added commandfiles:test. - Added driver abilities to select better driver.
Driver changes:
- Added
NelexaZippure-PHP driver. - Added
Isodriver extraction ability. - Added commenting-ability for
SevenZipdriver (viadescript.ionfile in archive).
-
-
1.1.528 Jun 2022Release notes
Open source →New features:
- Reimplemented
cam(console utility) - now it's on symfony/console and supports all features and more functions (folders, types) of UA. - Added more detailed installation instructions (
./vendor/bin/cam system:drivers) of specific drivers: AlchemyZippy, Cab, Iso, Lzma, Rar, SevenZip, TarByPear. - Added ability to track progress of archive creation - new argument
?callable $fileProgressCallableofUnifiedArchive::archiveFiles(). - Added ability to pass few directories to be placed in one in-archive directory in archiving/appending (
addFiles()/archiveFiles())[ '' => ['./folder1', './folder2'], 'README.md' => './subfolder/README.md' ] # Archive will have all folder1, folder2 contents in the root and README.md
Fixed:
- Fixed
extract()andlistContent()and their result of PclZip interface (UnifiedArchive::getPclZipInterface()) to correspond to original library (object => array). - Added tests on archiving, extraction and for PclZip-interface.
Format changes:
- Fixed counting of extracted files when extracting the whole archive in
TarByPear, TarByPhar, Zip. - Fixed calculation archive entry compressed size (approximately) and modification time, implemented entry content streaming in
TarByPhar.
Release notes
Open source →New features:
- Reimplemented
cam(console utility) - now it's on symfony/console and supports all features and more functions (folders, types) of UA. - Added more detailed installation instructions (
./vendor/bin/cam system:drivers) of specific drivers: AlchemyZippy, Cab, Iso, Lzma, Rar, SevenZip, TarByPear. - Added ability to track progress of archive creation - new argument
?callable $fileProgressCallableofUnifiedArchive::archiveFiles(). - Added ability to pass few directories to be placed in one in-archive directory in archiving/appending (
addFiles()/archiveFiles())[ '' => ['./folder1', './folder2'], 'README.md' => './subfolder/README.md' ] # Archive will have all folder1, folder2 contents in the root and README.md
Fixed:
- Fixed
extract()andlistContent()and their result of PclZip interface (UnifiedArchive::getPclZipInterface()) to correspond to original library (object => array). - Added tests on archiving, extraction and for PclZip-interface.
Format changes:
- Fixed counting of extracted files when extracting the whole archive in
TarByPear, TarByPhar, Zip. - Fixed calculation archive entry compressed size (approximately) and modification time, implemented entry content streaming in
TarByPhar.
- Reimplemented
-
1.1.421 Dec 2021 -
1.1.302 May 2021Release notes
Open source →Changed format of
$filesinarchiveFiles()andaddFiles()[ '/var/www/log.txt', // will be "/var/www/log.txt" 'log2.txt' => '/var/www/log2.txt', // will be "/log2.txt" '/var/www/site', // will be "/var/www/site" 'site2' => '/var/www/site2', // will be "/site2" ]Old format also works, but there can be a bad case. If you have /var/www/log2.txt and log2.txt (in current directory) and pass following:
[ '/var/www/log2.txt' => 'log2.txt', ]it will archive log2.txt as /var/www/log2.txt in an archive (new behaviour).
New features:
- Added
Formats::canStream()to check if an archive files can be streamed. - Added ability to create archives, encrypted with password (only zip (
Zip,SevenZip) and 7z (SevenZip)) - added nullable$passwordargument to:UnifiedArchive::archiveFiles($fileOrFiles, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)UnifiedArchive::archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)UnifiedArchive::archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null)
- Added
UnifiedArchive->getMimeType()to get mime type of archive. - Added
UnifiedArchive->getComment()to get comment of an archive. Available only inZipandRardrivers, others returnnull. - Added
UnifiedArchive->setComment(?string $comment)to set comment. Available only inZip. - Added filter in
UnifiedArcihve->getFileNames(). If works asfnmatch()does. - Added ability to iterate over archive and access files data as array:
$a = \wapmorgan\UnifiedArchive\UnifiedArchive::open('tests/archives/fixtures.7z'); foreach ($a as $file => $data) { echo $file.PHP_EOL; } $file_data = $a['filename'];Fixed:
- Fixed
SevenZipdriver: disabled tar.gz, tar.bzip2 support as it isn't supported properly and described which formats driver can create, append, modify and encrypt.
Methods renamed (old exist, but marked as deprecated):
UnifiedArchive->getArchiveFormat->UnifiedArchive->getFormat.UnifiedArchive->getArchiveSize->UnifiedArchive->getSize.UnifiedArchive->countCompressedFilesSize->UnifiedArchive->getCompressedSize.UnifiedArchive->countUncompressedFilesSize->UnifiedArchive->getOriginalSize.UnifiedArchive->getFileResource->UnifiedArchive->getFileStream.UnifiedArchive->isFileExists->UnifiedArchive->hasFile.
- Added
-
1.1.201 Mar 2021Release notes
Open source →Fixed calculation of tar's uncompressed size opened via
TarByPeardriver. Fixed working with tar.xz archives. -
1.1.113 Feb 2021 -
1.1.013 Feb 2021Release notes
Open source →New features:
- Added ability to open archives encrypted with password - added
$passwordargument toUnifiedArchive::open($fileName, $password = null). Works only with: zip, rar, 7z. - Added ability to adjust compression level for new archives - added
$compressionLevelargument (with defaultBasicDriver::COMPRESSION_AVERAGElevel) to:UnifiedArchive::archiveFiles($fileOrFiles, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE)UnifiedArchive::archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE)UnifiedArchive::archiveDirectory($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE)Works only with: zip, gzip.
- Added ability to append the archive with a file from string - added
addFileFromStringmethod:UnifiedArchive->addFileFromString(string $inArchiveName, string $content). - Added tests for format support:
Formats::canOpen()Formats::canCreate()Formats::canAppend()- check if file can be added to an archiveFormats::canUpdate()- check if archive member can be removedFormats::canEncrypt()- check if encrypted archive can be opened
Format changes:
- Extended SevenZip driver: now it supports a lot of formats (7z, zip, rar, iso, tar and so on).
- Added AlchemyZippy driver: it works via command-line programs for zip, tar, tar.gz and tar.bz2.
Methods renamed:
UnifiedArchive::canOpenType->Formats::canOpenUnifiedArchive::canOpenArchive->UnifiedArchive::canOpenUnifiedArchive::canCreateType->Formats::canCreateUnifiedArchive->getArchiveType->UnifiedArchive->getArchiveFormat- Old methods exist, but marked as deprecated.
- Added ability to open archives encrypted with password - added
-
1.0.128 Nov 2020Release notes
Open source →- Improved extendable for all classes - used late-static binding everywhere.
Format specific:
- gzip: improved detection of archive by content.
-
1.0.013 Jun 2020Release notes
Open source →Format specific:
- tar:
- Fixed automatic opening of .tar.Z and .tar.xz.
- rar:
- Exclude directories from files list.
- tar:
-
0.2.002 Feb 2020Release notes
Open source →BC-breaking changes:
- Deleted deprecated UnifiedArchive methods:
extractNode,archiveNodes. - Functionality of preparing files list for archiving is moved from
archiveFiles()toprepareForArchiving(). - All mutable methods throws exceptions on errors now:
getFileData,getFileContent,getFileResourcethrowsNonExistentArchiveFileExceptionwhen file is not present in archive.extractFilesthrows:EmptyFileListExceptionArchiveExtractionException
deleteFiles,addFiles,addFileandaddDirectorythrows:EmptyFileListExceptionUnsupportedOperationExceptionArchiveModificationException
archiveFiles,archiveFileandarchiveDirectorythrows:FileAlreadyExistsExceptionEmptyFileListExceptionUnsupportedOperationExceptionArchiveCreationException
- Deleted deprecated UnifiedArchive methods:
-
0.1.313 Jan 2020Release notes
Open source →BC-breaking changes:
- Minimal version is 5.5.0.
Format specific:
- zip: Fixed PclZip-interface
- 7zip: Fixed 7z-archiving, when archiving files should be renamed in archive
- lzw: Fixed check for availability (#15)
New features:
- Added
canCreateType(): bool - Added
canAddFiles(): bool - Added
canDeleteFiles(): bool
-
0.1.203 Jan 2019Release notes
Open source →BC-breaking changes:
- PclZip-interface getter renamed to
getPclZipInterface(). - Make
addFiles()return number of added files instead of total files number.
Other changes:
- Make
addFiles()/deleteFiles()/archiveFiles()throw\Exceptions when any error occurred (and even when files list is empty). - Fixed usage of
/always as directory separator inaddFiles()andarchiveFiles().
Format-specific changes:
- Divided format-specific code into separate components.
- zip:
- Excluded directories from files list (
getFileNames()). - Fixed retrieving new list of files after
addFiles()usage. - (#11) Fixed invalid "/" archive entry after
archiveFiles()usage.
- Excluded directories from files list (
- tar (
TarArchiveadapter):- Fixed number of added files of
addFiles(). - Fixed list of files after
deleteFiles()usage. - Added checks for compressed tar's support in
canOpenArchive()andcanOpenType().
- Fixed number of added files of
- tar (
PharDataadapter):- Fixed list of files after
addFiles()/deleteFiles()usage and path generation of archive inarchiveFiles(). - Fixed path of files in
getFileNames()to use UNIX path separator ("/").
- Fixed list of files after
- iso:
- Excluded directories from files list (
getFileNames()).
- Excluded directories from files list (
- 7zip:
- Fixed result of
deleteFiles()andarchiveFiles()in-archive paths. - Fixed calculation of compressed file size in
getFileData(). - (#10) Set infinite timeout of
7zsystem call (useful for big archives).
- Fixed result of
- cab:
- Fixed
extractFiles()functionality.
- Fixed
- PclZip-interface getter renamed to
-
0.1.118 Sep 2018Release notes
Open source →API changes:
-
Changed algorithm of files list generation in
archiveFiles()andaddFiles():// 1. one file $archive->archiveFiles('/var/www/site/abc.log', 'archive.zip'); // => stored as 'abc.log' // 2. directory $archive->archiveFiles('/var/www/site/runtime/logs', 'archive.zip'); // => directory content stored in archive root // 3. list $archive->archiveFiles([ '/var/www/site/abc.log' => 'abc.log', // stored as 'abc.log' '/var/www/site/abc.log', // stored as '/var/www/site/abc.log' '/var/www/site/runtime/logs' => 'logs', // directory content stored in 'logs' dir '/var/www/site/runtime/logs', // stored as '/var/www/site/runtime/logs' ], 'archive.zip'); -
Disabled paths expanding in
extractFiles()anddeleteFiles()by default.If you need to expand
src/path to all files within this directory in archive, set second argument$expandFilesListargument totrue.$archive->extractFiles(__DIR__, 'src/', true); $archive->deleteFiles('tests/', true); -
Added new element in
archiveFiles()result in emulation mode. Now it returns an archive with 4 elements: newtypeelement with archive type.
Fixes:
- Fixed LZW-stream (.tar.Z) wrapper (before it didn't work).
- Fixed ISO archives reading (before archive size could be calculated wrong).
- Fixed CAB archives extraction in
getFileContent($file)(before it didn't work). - Improved extraction in
getFileContent($file)for RAR archives by using streams (before it did extract file in temporarily folder, read it and then delete it).
Improvements:
- Added
isFileExists($file): boolmethod for checking if archive has a file with specific name. - Added
getFileResource($file): resourcemethod for getting a file descriptor for reading all file content without full extraction in memory. - Added
canOpenArchive($archiveFileName): boolandcanOpenType($archiveFormat): boolstatic methods to check if specific archive or format can be opened. - Added
detectArchiveType($fileName): string|falsestatic method to detect (by filename or content) archive type. - Added
addFile($file, $inArchiveName = null)/addDirectory($directory, $inArchivePath = null)to add one file or one directory,archiveFile($file, $archiveName)/archiveDirectory($directory, $archiveName)to archive one file or directory.
Miscellaneous:
- Added simple tests.
- Added
phardistribution.
-
-
0.1.001 Apr 2018Release notes
Open source →API changes:
- Renamed methods
extractNode()→extractFiles(),archiveNodes()→archiveFiles(). Original method are still available with@deprecatedstatus. getFileData()now returnsArchiveEntryinstance instead ofstdClass. Original object fields are still available with@deprecatedstatus.addFiles()anddeleteFiles()now return false when archive is not editable.
Improvements:
- Added checks of archive opening status in constructor: now an
Exceptionwill be throwed if archive file is not readable. - Some changes in
archiveNodes()about handling directory names. - Fixed archive rescan in
addFiles()anddeleteFiles().
Miscellaneous:
- Removed example scripts (
examples/). - Code changes: added comments.
- Renamed methods
-
0.1.0-alpha25 Mar 2018 pre-releaseNothing published for this version
-
0.0.1119 Mar 2018Release notes
Open source →- Cleaned up some old code.
- Added
ext-pharadapter for tar archives (ifpear/archive_taris not installed).
-
0.0.1007 Aug 2017 -
0.0.920 Jul 2017 -
0.0.824 Jan 2017Release notes
Open source →- Added initial support for
CABarchives without extracting. - Added handling of short names of tar archives (.tgz/.tbz2/...).
- Removed external repository declaration.
- Removed
die()in source code.
- Added initial support for
-
0.0.714 Jan 2017 -
0.0.609 Jan 2017Release notes
Open source →- Added functionality for adding files in archive.
- Added functionality for deleting files from archive.
- Fixed discovering
7zarchive number of files and creating new archive.
-
0.0.508 Jan 2017 -
0.0.407 Jan 2017 -
0.0.318 Aug 2015 -
0.0.227 May 2014 -
0.0.126 May 2014