UnifiedArchive - an archive manager with unified interface for different formats (bundled with cli utility). Supports all formats with basic operations (reading, extracting and creation) and popular formats specific features (compression level, password-protection, comment)
can()
instead.add()
instead.fileOrFiles
handling: if passed string, then file/directory will be archived with full its original name (as opposed to relative name before).test()
functionality - returns list of mismatched hashes.Fixed pure tar driver.
Fixed detection of archive format by it's content
Fixed:
UnifiedArchive->getComment()
now returns null when comment is not supported by driver (#39)UnifiedArchive->getFileData()->modificationTime
is integer timestamp now in case of NelexaZip driver instead of DateTimeImmutable (#38)PharData::create
for zip-archivesDeprecations:
UnifiedArchive
:
getFileNames
=> getFiles
extractFiles
=> extract
addFiles
=> add
deleteFiles
=> delete
archiveFiles
=> archive
canOpenArchive
=> canOpen
UnifiedArchive::detectArchiveType
- use Formats::detectArchiveFormat
insteadUnifiedArchive::archiveDirectory
/archiveFile
- use UnifiedArchive::archive
insteadUnifiedArchive::canCreateType
- Formats::canCreate
New functions:
Formats::getFormatExtension($archiveFormat)
UnifiedArchive->prepareForArchiving($fileOrFiles, $archiveName = null)
UnifiedArchive::createInString()
and BasicDriver::CREATE_IN_STRING
ability constantopen
does not throw an Exception, it returns nullcanOpenArchive
, canOpenType
, canCreateType
, getArchiveType
, detectArchiveType
, getFileResource
, getArchiveFormat
, isFileExists
, getArchiveSize
, countCompressedFilesSize
, countUncompressedFilesSize
.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).
open
throws an Exception when format is not recognized or there's no driver that support requested abilities.
addFiles
/deleteFiles
/getComment
/setComment
throws 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:
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
UnifiedArchive::test($files = [])
(and cam files:test
command) to test archive contents (compare actual control sum with stored crc32).system:drivers
, system:formats
, system:format
, added command files:test
.Driver changes:
NelexaZip
pure-PHP driver.Iso
driver extraction ability.SevenZip
driver (via descript.ion
file in archive).New features:
cam
(console utility) - now it's on symfony/console and supports all features and more functions (folders, types) of UA../vendor/bin/cam system:drivers
) of specific drivers: AlchemyZippy, Cab, Iso, Lzma, Rar, SevenZip, TarByPear.?callable $fileProgressCallable
of UnifiedArchive::archiveFiles()
.addFiles()
/archiveFiles()
)
[
'' => ['./folder1', './folder2'],
'README.md' => './subfolder/README.md'
] # Archive will have all folder1, folder2 contents in the root and README.md
Fixed:
extract()
and listContent()
and their result of PclZip interface (UnifiedArchive::getPclZipInterface()
) to correspond to original library (object => array).Format changes:
TarByPear, TarByPhar, Zip
.TarByPhar
.Disabled rar
for SevenZip driver.
Changed format of $files
in archiveFiles()
and addFiles()
[
'/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:
Formats::canStream()
to check if an archive files can be streamed.Zip
, SevenZip
) and 7z (SevenZip
)) - added nullable $password
argument 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)
UnifiedArchive->getMimeType()
to get mime type of archive.UnifiedArchive->getComment()
to get comment of an archive. Available only in Zip
and Rar
drivers, others return null
.UnifiedArchive->setComment(?string $comment)
to set comment. Available only in Zip
.UnifiedArcihve->getFileNames()
. If works as fnmatch()
does.$a = \wapmorgan\UnifiedArchive\UnifiedArchive::open('tests/archives/fixtures.7z');
foreach ($a as $file => $data) {
echo $file.PHP_EOL;
}
$file_data = $a['filename'];
Fixed:
SevenZip
driver: 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
.Fixed calculation of tar's uncompressed size opened via TarByPear
driver.
Fixed working with tar.xz archives.