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.1(9mo ago)1061.4M↑17.6%35[5 issues](https://github.com/splitbrain/php-archive/issues)[1 PRs](https://github.com/splitbrain/php-archive/pulls)17MITPHPPHP &gt;=7.0CI failing

Since Feb 25Pushed 9mo 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 1mo ago

READMEChangelogDependencies (2)Versions (21)Used By (17)

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.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance55

Moderate activity, may be stable

Popularity56

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 72.4% 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 ~211 days

Recently: every ~405 days

Total

19

Last Release

291d 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://www.gravatar.com/avatar/2851a48718937a41d7cc7ea185ec0ad95f3d5e4892e1693ed4f19b08a3f1e4ca?d=identicon)[splitbrain](/maintainers/splitbrain)

---

Top Contributors

[![splitbrain](https://avatars.githubusercontent.com/u/86426?v=4)](https://github.com/splitbrain "splitbrain (76 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.

4967.4M112](/packages/nelexa-zip)[zanysoft/laravel-zip

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

3142.8M15](/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.

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

Smart compressed files extractor

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

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

7661.0M73](/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.

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

PHPackages © 2026

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