• Stars
    star
    274
  • Rank 150,274 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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)

UnifiedArchive - an archive manager with unified interface for different formats that works on wide variety of system configuration. It supports all basic operations on widespread formats and some format-specific features for most popular ones (zip, rar, 7z, tar).

Main purpose of this library is to create unified interface for popular archive formats, that works in various system configurations via different drivers, when there is no ability to update system configuration, when code delivered to another system configurations, or when you just want to install libraries and work. It's handy when there's need to support archive types regardless of the system configuration.

Latest Stable Version Total Downloads Daily Downloads License Latest Unstable Version

Tests & Quality: Scrutinizer Code Quality Code Coverage

  1. Functions & Features
  2. How it works
  3. Quick start
  4. Built-in console archive manager
  5. Usage
  6. Drivers & formats
  7. Full API description
  8. Changelog

Functions & Features

UnifiedArchive is aimed to provide all operations on popular archive formats (zip, tar, rar, 7z) by all means and at better performance (depends on your OS/PHP configuration). Also, it allows to work with less popular archive types (with lack of functions).

Main functions:

  • Open an archive with automatic format detection (more 20 formats).
  • List archive content, calculate original size of archive
  • Get details (original size, date of modification) of every archived file. Extract or stream archived file content
  • Extract all archive content. Append an archive with new files or directories. Remove files from archive
  • Create new archives with files/directories on disk and stream from memory
  • Fully implemented PclZip-like interface for archives for all formats. Easy transition from old PclZip.
  • Bundled with cli utility

Specific functions:

How it works

UnifiedArchive uses "drivers", which can be one of types:

  1. PHP Extensions
  2. Utilities + bridge
  3. Pure PHP

By default, UA goes top-down to select first available driver for passed archive. So, PHP Extension driver will be used (if available), then Utilities + bridge driver (if available), and then Pure PHP driver.

There is at least one driver in all three types, which handles zip format, so this format can be fully supported in any OS/PHP configuration:

  1. zip / phar PHP extensions
  2. Utility + bridge SevenZip / AlchemyZippy
  3. Pure NelexaZip

tar format (with compressed variants) supported by:

  1. phar PHP extension
  2. Utility + bridge SevenZip / AlchemyZippy
  3. Pure TarByPear

So, there is always one driver that supports popular formats, and you should not remember how to work with this concrete driver (zip/phar/SevenZip/AlchemyZippy/NelexaZip), interface for them is uniform.

Quick start

Installation and configuration

Install library

composer require wapmorgan/unified-archive
#Check supported formats with installed drivers
./vendor/bin/cam system:formats
#Check supported functions for zip format
./vendor/bin/cam system:format zip

Install new driver

#Read installation instructions from
./vendor/bin/cam system:drivers
#install missing drivers, for example pear/archive_tar
composer require pear/archive_tar
#check out driver functions
./vendor/bin/cam system:formats TarByPear

#if needed, install extensions, cli tools and php libraries
#to enable support of other formats

Usage

use \wapmorgan\UnifiedArchive\UnifiedArchive;

$output_dir = '/var/www/extracted';

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

if (disk_free_space($output_dir) < $archive->getOriginalSize()) {
    throw new \RuntimeException('No needed space available. Need ' . ($archive->getOriginalSize() - disk_free_space($output_dir)) . ' byte(s) more');
}

$extracted = $archive->extract($output_dir);
echo 'Number of extracted files' . $extracted.PHP_EOL;

# Archiving
UnifiedArchive::create([
    'README.md' => '/default/path/to/README.md',
    '' => '/folder/with/content/',
], 'archive.zip');

Built-in console archive manager

UnifiedArchive is distributed with a unified console program to manipulate archives. It supports all formats and all operations on them that UnifiedArchive does, so it can be used to manipulate archives without other system software. To show help, launch it:

./vendor/bin/cam list # help
./vendor/bin/cam archive:info archive.tar.gz # archive information
./vendor/bin/cam files:list -l archive.tar.gz # files list (or files:table for table)
./vendor/bin/cam archive:extract archive.tar.gz ./OUTPUT/ # extraction all archive
./vendor/bin/cam archive:create --compression=maximum archive2.tar.gz ./OUTPUT/partners # archive creation from files

More Repositories

1

Morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time intervals. / Морфологическая библиотека для английского и русского языков. Склоняет имена собственные, названия географических объектов, склонение и плюрализация имен собственных и другое.
PHP
783
star
2

PhpDeprecationDetector

Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.
PHP
365
star
3

MediaFile

A unified reader of metadata from audio & video files.
PHP
156
star
4

Mp3Info

The fastest PHP library to extract mp3 meta information (duration, bitrate, samplerate and so on) and tags (id3v1, id3v2).
PHP
138
star
5

PhpCodeAnalyzer

PhpCodeAnalyzer scans codebase and analyzes which non-built-in php extensions used
PHP
96
star
6

TimeParser

A parser for date and time written in natural language for PHP.
PHP
95
star
7

Threadable

Easy-to-use threading library providing all basic features to perform work in background mode (with simulation mode).
PHP
77
star
8

java_for_beginners_book

71
star
9

SystemDaemon

Simple base for system daemons
PHP
60
star
10

BinaryStream

BinaryStream - a writer and reader for binary data. Best replacement for pack()/unpack().
PHP
52
star
11

csharp_for_beginners

49
star
12

Morphos-Blade

Morphos adapter for Blade
PHP
34
star
13

NcursesObjects

This is a php library that provides ncurses functionality in OOP way
PHP
34
star
14

FileTypeDetector

Detects file type by filename or content and generates correct mimetype.
PHP
33
star
15

yii2-inflection

Inflection extension for Yii2. Support for English / Russian languages to inflect words / names / numbers / money / date&time.
PHP
31
star
16

Imagery

Imagery simplifies image manipulations.
PHP
25
star
17

awesome-webservice

A curated list of awesome web services.
25
star
18

OpenApiGenerator

OpenApi configuration generator directly from PHP code (PhpDoc and php type hints). Can be used with a large monolithic backend
PHP
19
star
19

php-rpm-packager

A simple rpm packager for PHP applications.
PHP
10
star
20

Morphos-Twig

Morphos adapter for Twig
PHP
9
star
21

OneCloudApi.php

API client for 1cloud.ru
PHP
6
star
22

CabArchive

CabArchive - reader of cab-archives
PHP
3
star
23

ImageEditor

Moved to
PHP
3
star
24

posvt_ipz

CSS
1
star
25

cpp_for_beginners_book

1
star