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.

Overview

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

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

  • Open an archive with automatic format detection (more 20 formats)
  • Open archives encrypted with password (zip, rar, 7z)
  • List archive content, calculate original size of archive, read (zip, rar) & set (zip) archive comment
  • Get details (original size, date of modification) of every archived file. Read archived file content as stream (zip, rar, gz, bz2, xz). Extract archived file content as is or on a disk
  • Extract all archive content
  • Append an archive with new files or directories
  • Remove files from archive
  • Creat new archives with files/directories
  • Adjust compression level (zip, gzip, 7zip) for new archives
  • Set passwords (7z, zip) for new archives

Quick start

composer require wapmorgan/unified-archive
# install php libraries for support: tar.gz, tar.bz2, zip
composer require pear/archive_tar alchemy/zippy
# if you can, install `p7zip` package in OS and `SevenZip` driver
sudo apt-get install p7zip-full && composer require gemorroj/archive7z
# install ext-rar for native work
pecl install rar

# Check supported formats
./vendor/bin/cam --formats

More information about formats support in formats page.

Use it in code:

# Extraction
$archive = \wapmorgan\UnifiedArchive\UnifiedArchive::open('archive.zip'); // archive.rar, archive.tar.bz2

if ($archive !== null) {
    $output_dir = '/var/www/extracted';
    if (disk_free_space($output_dir) > $archive->getOriginalSize()) {
        $archive->extractFiles($output_dir);
        echo 'Extracted files list: '.implode(', ', $archive->getFileNames()).PHP_EOL;
    }
}

# Archiving
\wapmorgan\UnifiedArchive\UnifiedArchive::archiveFiles([
    'README.md' => '/default/path/to/README.md',
    'content' => '/folder/with/content/',
], 'archive.zip', \wapmorgan\UnifiedArchive\Drivers\BasicDriver::COMPRESSION_MAXIMUM);

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

Details

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

    getResource method

    Would it be possible to add a method to get the raw resource? My use case is that i have a bunch of text file in a zip file. I didn't inspect the code of this package but i assume it's using functions like https://secure.php.net/manual/en/function.zip-open.php which give back a resource. Then the resource can be used to pass to file() yes file also takes streams and such. So then i can split my text files into an array of lines. Right now i think the best option would be to use getFileContents (from the API) and then preg_split('/\R/', $str);. But working on resources is just nice for a bunch of things so might be worthwhile adding a method to get the resource, and possibly a method to get the file as an array of lines.

    opened by flip111 9
  • what if i don't want to use pear ?

    what if i don't want to use pear ?

    Hi. Your code is awesome!

    I tried to unpack tar.gz archive but i have no pear library installed. And i do not plan use it in the future. I suggest you unpack tar.gz with PharData php-class instead. It can to extract tar archives too.

    try {
              $phar = new PharData($archive_filename);
              $phar->extractTo($dest_directory, null, true);
    } catch (Exception $e) {}
    
    

    See this check https://github.com/wapmorgan/UnifiedArchive/blob/a51121f88ec7a6f699e499b2c0cae1db03d2c37e/src/UnifiedArchive.php#L60

    opened by abolabo 8
  • Exclude dev files from dist package

    Exclude dev files from dist package

    For the time being, when fetching the dist package from composer, all repository files are included. Using export-ignore git attribute would permit to make the dist package ligther (see https://php.watch/articles/composer-gitattributes#export-ignore).

    opened by cedric-anne 6
  • Extract archive with a folder at his root not working

    Extract archive with a folder at his root not working

    Describe the bug When I try to extract an archive created with a folder as source, I got this error back :

    Warning: ZipArchive::extractTo(/Users/olivierbossel/data/web/dwarvesforge/thorin/data/extracted/): failed to open stream: Is a directory in /Users/olivierbossel/data/web/dwarvesforge/thorin/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 689
    

    Configration (please complete the following information):

    • OS: OSX
    • Version: 10.13.6

    To Reproduce

    1. Zip a folder with an image inside like so:
    UnifiedArchive::archiveFiles('my-folder', 'my-archive.zip');
    
    1. Unzip the created archive like so:
    $archiveInstance = UnifiedArchive::open('my-archive.zip');
    $archiveInstance->extractFiles('folder-to-extract-to');
    

    Expected behavior I expect that my archive will be extracted and that I get back a folder structure like so: | folder-to-extract-to |--- my-folder |------ my-image.jpg

    Thanks in advance! And thanks for your nice job on this library! Cheers!

    bug 
    opened by olivierbossel 6
  • Creating a tar.gz file also creates a .tar file

    Creating a tar.gz file also creates a .tar file

    Describe the bug

    I'm creating a tar.gz file with something like:

    UnifiedArchive::archiveDirectory($path, 'file.tar.gz');
    

    The result is 2 files gets created: file.tar and file.tar.gz.

    I'm manually deleting .tar on my implementation but wanted to check if there is any reason for keeping it, I can open a PR to fix this behavior, just wanted to check first.

    opened by dbpolito 5
  • Not working in php 5.6

    Not working in php 5.6

    Hi,

    I tried to use the package in system running on php 5.6 but got the below error. Static function wapmorgan\UnifiedArchive\AbstractArchive::open() should not be abstract

    UnifiedArchive::open($image_path)

    Do you have any idea?

    opened by disiri 5
  • rar error massage problem

    rar error massage problem

    There is one file shows error like this

    An uncaught Exception was encountered Type: RarException

    Message: unRAR internal error: Failed to open /var/www/sub/2020/01/157838650259114.rar: ERAR_BAD_ARCHIVE

    Filename: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php

    Line Number: 34

    Backtrace:

    File: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php Line: 34 Function: open

    File: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php Line: 24 Function: open

    File: /var/www/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php Line: 257 Function: __construct

    File: /var/www/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php Line: 106 Function: __construct

    AND i try everthing to avoid the error , it still there .. i saw the doc said if there is mistake it will return null .. but it's not ..

    opened by jackzp 4
  • open($fileName, password: given) broken

    open($fileName, password: given) broken

    The square-brackets at the RHS must vanish:

    https://github.com/wapmorgan/UnifiedArchive/blob/876ab148b4a56e266266bec506301fa1263e0c0d/src/UnifiedArchive.php#L83

    Otherwise just specifying a password will lead to "array to string conversion" errors. Of course, the work-around is to specify options explicitly. I think this would be a good candidate for a hot-fix release.

    Thx for this package!

    opened by rotdrop 3
  • Extract RAR file error

    Extract RAR file error

    I have successfuly extract RAR file with extractFiles() but the error is still been thrown.

    Error: "Could not extract archive: The command "'/usr/bin/7z' 'x' '/var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar' '-aoa' '-o/var/www/project/storage/app/tmp/test' '-y' '-p '" failed.\n\nExit Code: 2(Misuse of shell builtins)\n\nWorking directory: /var/www/project/public\n\nOutput:\n================\n\n7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\np7zip Version 16.02 (locale=C,Utf16=off,HugeFiles=on,64 bits,1 CPU AMD FX(tm)-6100 Six-Core Processor (600F12),ASM,AES-NI)\n\nScanning the drive for archives:\n1 file, 4359357 bytes (4258 KiB)\n\nExtracting archive: /var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar\n--\nPath = /var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar\nType = Rar5\nPhysical Size = 4359357\nSolid = -\nBlocks = 7\nEncrypted = -\nMultivolume = -\nVolumes = 1\n\n\nSub items Errors: 3\n\nArchives with Errors: 1\n\nSub items Errors: 3\n\n\nError Output:\n================\nERROR: Unsupported Method : jsRar/images_1/testCopy.png\nERROR: Unsupported Method : jsRar/images_1/testCopy2.jpg\nERROR: Unsupported Method : jsRar/images_2/eBa.png\n"

    opened by DrobnjakS18 3
  • Fix PHP 8.1 deprecation log

    Fix PHP 8.1 deprecation log

    Fixes following errors seen while tests on PHP 8.1 RC environment.

    Adding the #[\ReturnTypeWillChange] attribute is the only way to prevent these deprecations errors while maintaining compatibility with PHP < 8.0.

    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 792:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 802:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 814:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 825:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 838:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 843:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 830:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 848:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 853:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    ==> Error E_DEPRECATED in /var/glpi/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 858:
    Return type of wapmorgan\UnifiedArchive\UnifiedArchive::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    
    opened by cedric-anne 3
  • Unable to extract a

    Unable to extract a ".tar.xz" archive

    Describe the bug When trying to open a tar.xz, the open function return null.

    Configration (please complete the following information):

    • OS: linux
    • Version of library: latest, PHP 8

    To Reproduce What I've done :

    • composer require wapmorgan/unified-archive
    • composer require pear/archive_tar
    • Installed xz extension https://github.com/codemasher/php-ext-xz via :
    RUN mkdir -p /tmp/php-ext-xz \
        && git clone https://github.com/codemasher/php-ext-xz.git /tmp/php-ext-xz \
        && docker-php-ext-configure /tmp/php-ext-xz \
        && docker-php-ext-install /tmp/php-ext-xz \
        && rm -r /tmp/php-ext-xz
    

    I'm working inside a docker container but the installation is OK, there is a xz extension loaded.

    My problem is when doing $archive = UnifiedArchive::open('archive.tar.xz'); the format found by UnifiedArchive is TAR_LZMA which require extension_loaded('lzma2') to be true in TarByPear.php.

    I don't have this extension and can't find anything on Google on how to install it for 1 hour now...

    What I find strange is, if I manually change the extension_loaded('lzma2') to extension_loaded('xz') in TarByPear.php line 71, the archive is correctly opened and I can use $archive->extractFiles('/tmp/'); without problem, the archive is decompressed and extracted...

    What I my missing, I'm going mad ! ^^

    I should add, I tried to change the extension of my archive to

    • .tar -> exception (UnexpectedValueException TarByPhar line 94)
    • .xz -> memory exhaustion (it seems it try to load the whole archive in memory)

    Hope it's a simple mistake on my end ! Help !

    opened by Tantrisse 3
  • mime_content_type($fileName) cannot work because of strtolower($fileName)

    mime_content_type($fileName) cannot work because of strtolower($fileName)

    Hi there,

    this line:

    https://github.com/wapmorgan/UnifiedArchive/blob/4a3a29d939a4520344e3405fa9ab8c77ae1b4143/src/Formats.php#L131

    makes the mime_content_check($fileName) fail at this point:

    https://github.com/wapmorgan/UnifiedArchive/blob/4a3a29d939a4520344e3405fa9ab8c77ae1b4143/src/Formats.php#L151

    At least when used with file-systems which are case sensitive.

    opened by rotdrop 0
  • Problem with deleting .zip file

    Problem with deleting .zip file

    Throws exectiopn while deleting .zip file file: "/var/www/project/vendor/wapmorgan/unified-archive/src/Drivers/Zip.php" message: "No such file"

    I don't have this problem when deleting files with .7z extension

    opened by DrobnjakS18 1
  • Extract tar.gz memory exhaustion

    Extract tar.gz memory exhaustion

    Describe the bug

    Error:

    Allowed memory size of 536870912 bytes exhausted (tried to allocate 512913866 bytes)
    

    The error explodes here: PharData

    Configration (please complete the following information):

    • OS: alpine
    • Version of library: latest

    To Reproduce

    Try to extract a file bigger than you max memory limit

    It seems it's loading the entire file in memory, is this expected?

    Interesting enough it works when extracting big gzip files

    opened by dbpolito 2
  • Compress no longer available

    Compress no longer available

    Describe the bug The compress command is no longer available on Debian based systems. It still appears to be available in Unix and BSD systems. In LzwStreamWrapp::checkBinary() there is a check for both compress and uncompress. When attempting to extract a .tar.Z file the extract fails because of the isBinaryAvailable() check but uncompress is in fact still available.

    The archive xmlfeed_lic475-2021_09_24.tar.Z could not be extracted. compress and uncompress commands are required

    Configration (please complete the following information):

    • OS: Ubuntu 20.04.3
    • Version of library: 1.4.14

    To Reproduce Attempt to extract a LZW compressed .tar.Z file on newer debian systems where compress is not available or installable.

    Expected behavior Perhaps there could be a separate check. If writing to the archive then check for compress? Please take a look at the below. If that works for you then I can submit a pull request

    Possible Fix

    /**
         * @throws \Exception
         */
        protected static function checkBinary($write = false)
        {
            if (self::$installed === null) {
                if (strncasecmp(PHP_OS, 'win', 3) === 0) {
                    self::$installed = false;
                } else {
                    self::exec('command -v compress', $output);
                    if ($write && empty($output)) {
                        self::$installed = false;
                    } else {
                        self::exec('command -v uncompress', $output);
                        if (empty($output)) {
                            self::$installed = false;
                        } else {
                            self::$installed = true;
                        }
                    }
                }
            }
        }
    
    /**
         * @param $data
         * @return bool|int
         */
        public function stream_write($data)
        {
            $this->checkBinary(true);
            if (self::$installed === false)
                throw new \Exception('compress and uncompress commands are required');
            $this->writtenBytes += strlen($data);
            if ($this->tmp !== null) {
                $fp = fopen($this->tmp, 'w'.(strpos($this->mode, 'b') !== 0 ? 'b'
                    : null));
                fseek($fp, $this->pointer);
                $count = fwrite($fp, $data);
                $this->pointer += $count;
                fclose($fp);
    
                return $count;
            } else {
                $count = strlen($data);
                $prefix = substr($this->data, 0, $this->pointer);
                $postfix = substr($this->data, ($this->pointer + $count));
                $this->data = $prefix.$data.$postfix;
                $this->pointer += $count;
    
                return $count;
            }
        }
    
    bug 
    opened by jasonhoule 1
  • Cannot access phar file entry '/' in archive 'myfile.tgz'

    Cannot access phar file entry '/' in archive 'myfile.tgz'

    Describe the bug

    When trying to extract a .tgz file with UnifiedArchive it reports the following error message: In Tar.php line 369: "Cannot access phar file entry '/' in archive 'myfile.tgz'"

    Doing the same with CLI commands gunzip myfile.tgz & tar xf myfile.tar works fine.

    Configuration

    • OS: linux debian 9.3
    • Version of library: 0.1.2
    • Satisfied Composer dependencies (selection) "php": "^7.0", "ext-phar": "", "ext-zip": "", "ext-zlib": "*", "pear/archive_tar": "~1.4.3", "wapmorgan/unified-archive": "^0.1"

    tar -tvf myfile.tar shows this (shortened list): drwxr-xr-x web/users 0 2019-01-11 02:10 ./ -rw-r--r-- web/users 15254 2019-01-11 02:10 ./myfile.xml

    To Reproduce

    $archive = UnifiedArchive::open($absoluteArchiveFilePath); $numberOfFiles = $archive->extractFiles($absoluteTargetDirPath);

    Expected behavior

    Contents of .tgz file should be extracted to the target directory.

    bug 
    opened by BigNerd 4
Releases(1.1.8)
  • 1.1.8(Nov 20, 2022)

    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()->modificationTime is integer timestamp now in case of NelexaZip driver instead of DateTimeImmutable (#38)
    • Fixed PharData::create for zip-archives

    Deprecations:

    • Renamed methods of UnifiedArchive:
      • getFileNames => getFiles
      • extractFiles => extract
      • addFiles => add
      • deleteFiles => delete
      • archiveFiles => archive
      • canOpenArchive => canOpen
      • Old methods are marked as deprecated and will be deleted in future releases.
    • Marked as deprecated:
      • UnifiedArchive::detectArchiveType - use Formats::detectArchiveFormat instead
      • UnifiedArchive::archiveDirectory/archiveFile - use UnifiedArchive::archive instead
      • UnifiedArchive::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() and BasicDriver::CREATE_IN_STRING ability constant
    • Added new pure driver for Zip/Tar(gz/bz2) - SplitbrainPhpArchive.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.7(Jul 30, 2022)

    • open does not throw an Exception, it returns null
    • returned deleted methods in UnifiedArchive: canOpenArchive, canOpenType, canCreateType, getArchiveType, detectArchiveType, getFileResource, getArchiveFormat, isFileExists, getArchiveSize, countCompressedFilesSize, countUncompressedFilesSize.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.6(Jul 30, 2022)

    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:

    • 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 = []) (and cam files:test command) to test archive contents (compare actual control sum with stored crc32).
    • More informative output in commands: system:drivers, system:formats, system:format, added command files:test.
    • Added driver abilities to select better driver.

    Driver changes:

    • Added NelexaZip pure-PHP driver.
    • Added Iso driver extraction ability.
    • Added commenting-ability for SevenZip driver (via descript.ion file in archive).
    Source code(tar.gz)
    Source code(zip)
  • 1.1.5(Jun 28, 2022)

    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 $fileProgressCallable of UnifiedArchive::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() and listContent() 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.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.4(Dec 21, 2021)

  • 1.1.3(May 2, 2021)

    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:

    • 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 $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)
    • Added UnifiedArchive->getMimeType() to get mime type of archive.
    • Added UnifiedArchive->getComment() to get comment of an archive. Available only in Zip and Rar drivers, others return null.
    • Added UnifiedArchive->setComment(?string $comment) to set comment. Available only in Zip.
    • Added filter in UnifiedArcihve->getFileNames(). If works as fnmatch() 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 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.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Mar 1, 2021)

  • 1.1.1(Feb 13, 2021)

  • 1.1.0(Feb 13, 2021)

    New features:

    • Added ability to open archives encrypted with password - added $password argument to UnifiedArchive::open($fileName, $password = null). Works only with: zip, rar, 7z.
    • Added ability to adjust compression level for new archives - added $compressionLevel argument (with default BasicDriver::COMPRESSION_AVERAGE level) 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 addFileFromString method: 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 archive
      • Formats::canUpdate() - check if archive member can be removed
      • Formats::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::canOpen
    • UnifiedArchive::canOpenArchive -> UnifiedArchive::canOpen
    • UnifiedArchive::canCreateType -> Formats::canCreate
    • UnifiedArchive->getArchiveType -> UnifiedArchive->getArchiveFormat

    Old methods exist, but marked as deprecated.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Nov 28, 2020)

    • Improved extendable for all classes - used late-static binding everywhere.

    Format specific:

    • gzip: improved detection of archive by content.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jun 13, 2020)

  • 0.2.0(Feb 2, 2020)

    BC-breaking changes:

    • Deleted deprecated UnifiedArchive methods: extractNode, archiveNodes.
    • All mutable methods throws exceptions on errors now:
      • getFileData, getFileContent, getFileResource throws NonExistentArchiveFileException when file is not present in archive.
      • extractFiles throws:
        • EmptyFileListException
        • ArchiveExtractionException
      • deleteFiles, addFiles, addFile and addDirectory throws:
        • EmptyFileListException
        • UnsupportedOperationException
        • ArchiveModificationException
      • archiveFiles, archiveFile and archiveDirectory throws:
        • FileAlreadyExistsException
        • EmptyFileListException
        • UnsupportedOperationException
        • ArchiveCreationException
    • Functionality of preparing files list for archiving is moved from archiveFiles() to prepareForArchiving().
    Source code(tar.gz)
    Source code(zip)
    cam.phar(484.74 KB)
  • 0.1.3(Jan 13, 2020)

    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
    Source code(tar.gz)
    Source code(zip)
    cam.phar(481.09 KB)
  • 0.1.2(Jan 3, 2019)

    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 in addFiles() and archiveFiles().

    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.
    • tar (TarArchive adapter):
      • Fixed number of added files of addFiles().
      • Fixed list of files after deleteFiles() usage.
      • Added checks for compressed tar's support in canOpenArchive() and canOpenType().
    • tar (PharData adapter):
      • Fixed list of files after addFiles()/deleteFiles() usage and path generation of archive in archiveFiles().
      • Fixed path of files in getFileNames() to use UNIX path separator ("/").
    • iso:
      • Excluded directories from files list (getFileNames()).
    • 7zip:
      • Fixed result of deleteFiles() and archiveFiles() in-archive paths.
      • Fixed calculation of compressed file size in getFileData().
      • (#10) Set infinite timeout of 7z system call (useful for big archives).
    • cab:
      • Fixed extractFiles() functionality.
    Source code(tar.gz)
    Source code(zip)
    cam.phar(614.23 KB)
  • 0.1.1(Sep 21, 2018)

    Important API changes:

    • Changed algorithm of files list generation in archiveFiles() and addFiles():

      // 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() and deleteFiles() by default.

      If you need to expand src/ path to all files within this directory in archive, set second argument $expandFilesList argument to true.

      $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: added type element 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): bool method for checking if archive has a file with specific name.
    • Added getFileResource($file): resource method for getting a file descriptor for reading all file content without full extraction in memory.
    • Added canOpenArchive($archiveFileName): bool and canOpenType($archiveFormat): bool static methods to check if specific archive or format can be opened.
    • Added detectArchiveType($fileName): string|false static 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 phar distribution.
    Source code(tar.gz)
    Source code(zip)
    cam.phar(436.23 KB)
  • 0.1.0(Apr 11, 2018)

    BC notes:

    • UnifiedArchive::extractNode() renamed → extractFiles(). Original method is still available with @deprecated status.
    • UnifiedArchive::archiveNodes() renamed → archiveFiles(). Original method is still available with @deprecated status.
    • UnifiedArchive::getFileData() now returns ArchiveEntry instead of stdClass. Original object fields are still available with @deprecated status.

    Main changes:

    • Added checks of archive opening status in UnifiedArchive constructor: now an Exception is throwing if archive is not readable.

    • addFiles() and deleteFiles() now return false when archive is not editable.

    • Some changes in archiveNodes() about handling directory names.

    • Fixed archive rescan in addFiles() and deleteFiles().

    • Removed example scripts (examples/).

    • Code changes: added comments.

    Source code(tar.gz)
    Source code(zip)
    cam.phar(193.38 KB)
  • 0.1.0-alpha(Mar 25, 2018)

    BC notes:

    • UnifiedArchive::extractNode() renamed → extractFiles(). Original method is still available with @deprecated status.
    • UnifiedArchive::archiveNodes() renamed → archiveFiles(). Original method is still available with @deprecated status.
    • UnifiedArchive::getFileData() now returns ArchiveEntry instead of stdClass. Original object fields are still available with @deprecated status.

    Main changes:

    • Added checks of archive opening status in UnifiedArchive constructor: now an Exception is throwing if archive is not readable.

    • addFiles() and deleteFiles() now return false when archive is not editable.

    • Some changes in archiveNodes() about handling directory names.

    • Fixed archive rescan in addFiles() and deleteFiles().

    • Removed example scripts (examples/).

    • Code changes: added comments,

    Source code(tar.gz)
    Source code(zip)
  • 0.0.11(Mar 21, 2018)

  • 0.0.10(Aug 7, 2017)

  • 0.0.9(Jul 20, 2017)

  • 0.0.8(Jan 24, 2017)

    Added:

    • Initial support for CAB archives without extracting.

    Changed:

    • Handling of short names of tar archives.
    • Removed external repository declaration.
    • Removed die() in source code.
    Source code(tar.gz)
    Source code(zip)
  • 0.0.7(Jan 14, 2017)

  • 0.0.6(Jan 9, 2017)

    Added:

    • Adding files in archive.
    • Deleting files from archive.

    Fixed:

    • Fixed discovering 7z archive number of files and creating new archive.
    Source code(tar.gz)
    Source code(zip)
  • 0.0.5(Jan 8, 2017)

  • 0.0.4(Jan 7, 2017)

  • 0.0.3(Aug 18, 2015)

  • 0.0.2(Aug 14, 2014)

A Flysystem proxy adapter that enables compression and encryption of files and streams on the fly

Slam / flysystem-compress-and-encrypt-proxy Compress and Encrypt files and streams before saving them to the final Flysystem destination. Installation

Filippo Tessarotto 27 Jun 4, 2022
A "Vuejs & Laravel" Media Manager With Tons of Features

Laravel Media Manager Installation Config Features Events Usage Installation composer require ctf0/media-manager publish the package assets with php a

Muah 783 Dec 29, 2022
A python program to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks.

I'm writing a python script to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks called ReCut. So far there are two

Dönerspiess 1 Oct 27, 2021
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build parse trees and also generates a listener interface (or visitor) that makes it easy to respond to the recognition of phrases of interest.

Antlr Project 13.6k Jan 6, 2023
Basic anonymous and registered upload storage for temporary share file self hosted.

TMPShareX Basic anonymous and registered upload storage for temporary share file self hosted. Server Requirement PHP 7.4.8 [Support PHP 8] Nginx 1.19.

Sandy Hermansyah 1 Feb 3, 2022
A lightweight file manager with full ShareX, Screencloud support and more

XBackBone is a simple, self-hosted, lightweight PHP file manager that support the instant sharing tool ShareX and *NIX systems. It supports uploading

Sergio Brighenti 751 Jan 8, 2023
kodbox is a file manager for web. It is a newly designed product based on kodexplorer.

kodbox is a file manager for web. It is a newly designed product based on kodexplorer. It is also a web code editor, which allows you to develop websites directly within the web browser.You can run kodbox either online or locally,on Linux, Windows or Mac based platforms

warlee 1.2k Jan 7, 2023
File manager module for the Lumen PHP framework.

Lumen File Manager File manager module for the Lumen PHP framework. Please note that this module is still under active development. NOTE: Branch 5.1 i

Digia 40 Aug 20, 2022
A web based file manager,web IDE / browser based code editor

KodExplorer Update to kodbox: https://github.com/kalcaddle/kodbox Download | Demo It is recommended to use a new design upgrade product:kodbox 该项目处于维护

warlee 5.8k Jan 3, 2023
A PHP library to deal with all those media services around, parsing their URLs and displaying their audios/videos.

MediaEmbed A utility library that generates HTML embed tags for audio or video located on a given URL. It also parses and validates given media URLs.

Mark Sch. 165 Nov 10, 2022
☁️ Nextcloud server, a safe home for all your data

Nextcloud Server ☁ A safe home for all your data. Why is this so awesome? ?? ?? Access your Data You can store your files, contacts, calendars and mor

Nextcloud 21.1k Dec 31, 2022
Private file storage and share with user build with laravel and vue inspired by google drive

LaravelDrive is a file storage system that allows store private file and share with users build wiht laravel and vue inspired by google drive. Laravel

Shahadat Hossain 70 Dec 22, 2022
Laravel Flysystem was created by, and is maintained by Graham Campbell, and is a Flysystem bridge for Laravel.

Laravel Flysystem Laravel Flysystem was created by, and is maintained by Graham Campbell, and is a Flysystem bridge for Laravel. It utilises my Larave

Graham Campbell 492 Feb 4, 2022
Abstraction for local and remote filesystems

League\Flysystem About Flysystem Flysystem is a file storage library for PHP. It provides one interface to interact with many types of filesystems. Wh

The League of Extraordinary Packages 12.7k Dec 30, 2022
Detects file type by filename or content and generates correct mimetype.

FileTypeDetector Files type detector based on file name extension or file content (binary content). Usage Installation Supported formats Usage File Ty

Sergey 31 Oct 6, 2022
Abstraction for local and remote filesystems

League\Flysystem About Flysystem Flysystem is a file storage library for PHP. It provides one interface to interact with many types of filesystems. Wh

The League of Extraordinary Packages 11.9k Apr 22, 2021
Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.

Uguu What is Uguu? Uguu is a simple lightweight temporary file hosting and sharing platform, but can also be used as a permanent file host. Features O

Eric Johansson (neku) 547 Dec 28, 2022
This small PHP package assists in the loading and parsing of VTT files.

VTT Transcriptions This small PHP package assists in the loading and parsing of VTT files. Usage use Laracasts\Transcriptions\Transcription; $transcr

Laracasts 52 Nov 28, 2022