PHPackages                             splitbrain/php-archive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. splitbrain/php-archive

ActiveLibrary[File &amp; Storage](/categories/file-storage)

splitbrain/php-archive
======================

Pure-PHP implementation to read and write TAR and ZIP archives

1.4.3(4w ago)1081.6M↓18.2%36[3 issues](https://github.com/splitbrain/php-archive/issues)19MITPHPPHP &gt;=7.0CI failing

Since Feb 25Pushed 2w ago6 watchersCompare

[ Source](https://github.com/splitbrain/php-archive)[ Packagist](https://packagist.org/packages/splitbrain/php-archive)[ GitHub Sponsors](https://github.com/sponsors/splitbrain)[ RSS](/packages/splitbrain-php-archive/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (6)Versions (24)Used By (19)

PHPArchive - Pure PHP ZIP and TAR handling
==========================================

[](#phparchive---pure-php-zip-and-tar-handling)

This library allows to handle new ZIP and TAR archives without the need for any special PHP extensions (gz and bzip are needed for compression). It can create new files or extract existing ones.

To keep things simple, the modification (adding or removing files) of existing archives is not supported.

Install
-------

[](#install)

Use composer:

`php composer.phar require splitbrain/php-archive`

Usage
-----

[](#usage)

The usage for the Zip and Tar classes are basically the same. Here are some examples for working with TARs to get you started.

Check the [API docs](https://splitbrain.github.io/php-archive/) for more info.

```
require_once 'vendor/autoload.php';
use splitbrain\PHPArchive\Tar;

// To list the contents of an existing TAR archive, open() it and use
// contents() on it:
$tar = new Tar();
$tar->open('myfile.tgz');
$toc = $tar->contents();
print_r($toc); // array of FileInfo objects

// To extract the contents of an existing TAR archive, open() it and use
// extract() on it:
$tar = new Tar();
$tar->open('myfile.tgz');
$tar->extract('/tmp');

// To create a new TAR archive directly on the filesystem (low memory
// requirements), create() it:
$tar = new Tar();
$tar->create('myfile.tgz');
$tar->addFile(...);
$tar->addData(...);
...
$tar->close();

// To create a TAR archive directly in memory, create() it, add*()
// files and then either save() or getArchive() it:
$tar = new Tar();
$tar->setCompression(9, Archive::COMPRESS_BZIP);
$tar->create();
$tar->addFile(...);
$tar->addData(...);
...
$tar->save('myfile.tbz'); // compresses and saves it
echo $tar->getArchive(); // compresses and returns it
```

Differences between Tar and Zip: Tars are compressed as a whole, while Zips compress each file individually. Therefore you can call `setCompression` before each `addFile()` and `addData()` function call.

The FileInfo class can be used to specify additional info like ownership or permissions when adding a file to an archive.

File name encoding
------------------

[](#file-name-encoding)

File names you pass to `addFile()`, `addData()` or a FileInfo object are expected to be UTF-8 encoded.

Zip archives record which encoding a name uses, so names read from a Zip are always returned as UTF-8. Names written outside the ASCII range are stored as UTF-8 and flagged as such, which is what current archivers expect.

Tar archives have no field for that. Names are written exactly as you pass them and returned exactly as they are stored. Anything written by a current tool uses UTF-8, but an older archive may use any encoding without saying so, and such names are returned unchanged. Use `mb_check_encoding()` if you need to know, and convert them yourself if you know what encoding they use.

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance94

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 74.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~208 days

Recently: every ~395 days

Total

21

Last Release

29d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

1.0.10PHP &gt;=5.4

1.3.0PHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/86426?v=4)[Andreas Gohr](/maintainers/splitbrain)[@splitbrain](https://github.com/splitbrain)

---

Top Contributors

[![splitbrain](https://avatars.githubusercontent.com/u/86426?v=4)](https://github.com/splitbrain "splitbrain (84 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (15 commits)")[![zozlak](https://avatars.githubusercontent.com/u/6503177?v=4)](https://github.com/zozlak "zozlak (6 commits)")[![jgmdev](https://avatars.githubusercontent.com/u/1702572?v=4)](https://github.com/jgmdev "jgmdev (4 commits)")[![mreiden](https://avatars.githubusercontent.com/u/6321246?v=4)](https://github.com/mreiden "mreiden (1 commits)")[![mobielbekeken-thijs](https://avatars.githubusercontent.com/u/40237628?v=4)](https://github.com/mobielbekeken-thijs "mobielbekeken-thijs (1 commits)")[![phallobst](https://avatars.githubusercontent.com/u/520841?v=4)](https://github.com/phallobst "phallobst (1 commits)")[![mferaru-bd](https://avatars.githubusercontent.com/u/138784935?v=4)](https://github.com/mferaru-bd "mferaru-bd (1 commits)")

---

Tags

compressionextractphpphp-librarytarziparchivetarzipextractunzipunpack

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/splitbrain-php-archive/health.svg)

```
[![Health](https://phpackages.com/badges/splitbrain-php-archive/health.svg)](https://phpackages.com/packages/splitbrain-php-archive)
```

###  Alternatives

[nelexa/zip

PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.

5018.2M157](/packages/nelexa-zip)[zanysoft/laravel-zip

laravel-zip is the world's leading zip utility for file compression and backup.

3213.0M15](/packages/zanysoft-laravel-zip)[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.

2821.8M7](/packages/wapmorgan-unified-archive)[raulfraile/distill

Smart compressed files extractor

228197.6k9](/packages/raulfraile-distill)[pear/archive_tar

Tar file management class with compression support (gzip, bzip2, lzma2)

7567.1M100](/packages/pear-archive-tar)[barracudanetworks/archivestream-php

A library for dynamically streaming dynamic tar or zip files without the need to have the complete file stored on the server.

77196.8k1](/packages/barracudanetworks-archivestream-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
