PHPackages                             horde/compress - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. horde/compress

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

horde/compress
==============

Compression library

v3.0.0(6d ago)23.9k↑51.8%46LGPL-2.1-onlyPHPPHP ^8.1

Since Jul 16Pushed 6d ago5 watchersCompare

[ Source](https://github.com/horde/Compress)[ Packagist](https://packagist.org/packages/horde/compress)[ Docs](https://www.horde.org/libraries/Horde_Compress)[ RSS](/packages/horde-compress/feed)WikiDiscussions FRAMEWORK\_6\_0 Synced yesterday

READMEChangelog (3)Dependencies (34)Versions (19)Used By (6)

Horde\\Compress
===============

[](#hordecompress)

A PHP library for creating and extracting compressed archives and encoded transport formats. Supports ZIP, TAR, GZIP, RAR (read-only), DBX (read-only) and for handling Microsoft TNEF (winmail.dat) decoding.

Installation
------------

[](#installation)

```
composer require horde/compress
```

### Optional dependencies

[](#optional-dependencies)

PackagePurpose`horde/stream_filter`CRC32 stream filter for ZIP compression with resource handles`horde/icalendar`iCalendar generation from TNEF meeting requests`horde/mapi`MAPI property decoding for TNEF attachments`horde/mail`RFC 822 address parsing in TNEF messages`ext-zlib`Required for Gzip driverUsage
-----

[](#usage)

### CompressFactory

[](#compressfactory)

```
use Horde\Compress\CompressFactory;

$factory = new CompressFactory();
$zip = $factory->create('zip');
$tar = $factory->create('tar');
$gzip = $factory->create('gzip');
```

Pass a PSR-3 logger to the factory for diagnostic output:

```
$factory = new CompressFactory($logger);
$zip = $factory->create('zip');
```

### Creating a ZIP archive

[](#creating-a-zip-archive)

```
use Horde\Compress\CompressFactory;
use Horde\Compress\Driver\Zip;

$zip = (new CompressFactory())->create('zip');

$files = [
    ['data' => 'Hello World', 'name' => 'hello.txt', 'time' => time()],
    ['data' => file_get_contents('image.png'), 'name' => 'image.png', 'time' => filemtime('image.png')],
];

$archive = $zip->compress($files);
file_put_contents('archive.zip', $archive);
```

### Extracting a ZIP archive

[](#extracting-a-zip-archive)

```
use Horde\Compress\Driver\Zip;

$zip = (new CompressFactory())->create('zip');
$data = file_get_contents('archive.zip');

// List contents
$listing = $zip->decompress($data, ['action' => Zip::ZIP_LIST]);
foreach ($listing as $entry) {
    echo $entry['name'] . ' (' . $entry['size'] . " bytes)\n";
}

// Extract a specific file by index
$content = $zip->decompress($data, ['action' => Zip::ZIP_DATA, 'info' => $listing, 'key' => 0]);
```

### Creating a TAR archive

[](#creating-a-tar-archive)

```
use Horde\Compress\CompressFactory;

$tar = (new CompressFactory())->create('tar');

$files = [
    ['data' => 'content', 'name' => 'file.txt', 'time' => time()],
];

$archive = $tar->compress($files);
file_put_contents('archive.tar', $archive);
```

### Compressing a directory

[](#compressing-a-directory)

```
$tar = (new CompressFactory())->create('tar');
$archive = $tar->compressDirectory('/path/to/directory');
```

### Decompressing GZIP data

[](#decompressing-gzip-data)

```
$gzip = (new CompressFactory())->create('gzip');
$raw = $gzip->decompress(file_get_contents('file.gz'));
```

### Decoding TNEF (winmail.dat)

[](#decoding-tnef-winmaildat)

```
use Horde\Compress\Tnef\TnefDecoder;

$decoder = new TnefDecoder();
$parts = $decoder->decompress(file_get_contents('winmail.dat'));

foreach ($parts as $part) {
    echo $part['name'] . ' (' . $part['type'] . '/' . $part['subtype'] . ")\n";
}

// Access message metadata
$msgInfo = $decoder->getMsgInfo();
echo 'Subject: ' . $msgInfo->subject . "\n";
```

### Reading RAR archives (listing only)

[](#reading-rar-archives-listing-only)

```
$rar = (new CompressFactory())->create('rar');
$listing = $rar->decompress(file_get_contents('archive.rar'));

foreach ($listing as $entry) {
    echo $entry['name'] . ' (' . $entry['size'] . " bytes)\n";
}
```

Architecture
------------

[](#architecture)

```
src/
├── Base.php                   # Abstract base class with logger support
├── CompressFactory.php        # Factory — creates driver instances by name
├── CompressorInterface.php    # Contract: compress, decompress, compressFiles, compressDirectory
├── Exception.php              # Library exception
├── Translation.php            # Gettext translation wrapper
├── Driver/
│   ├── Dbx.php                # Outlook Express DBX mailbox extraction
│   ├── Gzip.php               # RFC 1952 gzip decompress
│   ├── Rar.php                # RAR archive listing (read-only)
│   ├── Tar.php                # POSIX tar create/extract, SplFileInfo support
│   └── Zip.php                # ZIP create/extract, stream resource support
└── Tnef/
    ├── BufferReaderTrait.php   # Binary buffer reading (little-endian ints)
    ├── Date.php                # TNEF date attribute → Horde_Date
    ├── File.php                # TNEF file attachment object
    ├── Icalendar.php           # TNEF meeting request → iCalendar
    ├── MessageData.php         # TNEF message envelope (subject, from, date)
    ├── Rtf.php                 # Compressed RTF extraction
    ├── TnefDecoder.php         # Main TNEF parser
    ├── TnefObject.php          # Base TNEF object
    ├── TnefObjectInterface.php # Contract for TNEF attribute handlers
    └── VTodo.php               # TNEF task → vTodo

```

Upgrading
---------

[](#upgrading)

See [doc/UPGRADING.md](doc/UPGRADING.md) for the migration guide from the legacy `Horde_Compress` (PSR-0) API to the modern `Horde\Compress` (PSR-4) API.

Requirements
------------

[](#requirements)

- PHP 8.1+
- `horde/exception` ^3
- `horde/mime` ^3
- `horde/translation` ^3
- `horde/util` ^3

License
-------

[](#license)

LGPL-2.1-only. See [LICENSE](LICENSE) for details.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance99

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community34

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~315 days

Recently: every ~427 days

Total

16

Last Release

6d ago

Major Versions

2.2.2 → 3.0.0alpha22021-02-24

2.2.4 → v3.0.0alpha42022-11-04

PHP version history (7 changes)2.0.5PHP &gt;=5.3.0

2.1.3PHP &gt;=5.3.0,&lt;=6.0.0alpha1

2.1.4PHP &gt;=5.3.0,&lt;=8.0.0alpha1

2.2.0PHP ^5.3 || ^7

3.0.0alpha2PHP ^7

v3.0.0alpha4PHP ^7.4 || ^8

v3.0.0beta2PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c943a083635c28520599075eaea7ede2d743b7697b76e84d6bdc37e52cc8249b?d=identicon)[yunosh](/maintainers/yunosh)

![](https://www.gravatar.com/avatar/c931cd02664859360478593450d6c473a05bb12b209dfacfc534cd13257cc7ef?d=identicon)[ralflang](/maintainers/ralflang)

![](https://www.gravatar.com/avatar/e4f6c6771993db2ed500959b42353f6cf6a2ca0406d9617f7ae680f4504faa4a?d=identicon)[horde](/maintainers/horde)

![](https://www.gravatar.com/avatar/a7767adb66b45f2f05bcd44d49bc4e67efacd9ce05b161ce2d481d5dd6af025c?d=identicon)[mrubinsk](/maintainers/mrubinsk)

![](https://www.gravatar.com/avatar/816e2b926f25f8cd2939054c7a7173011b4303d690e25ab61bf33cf8c7cf71ae?d=identicon)[tdannhauer](/maintainers/tdannhauer)

---

Top Contributors

[![yunosh](https://avatars.githubusercontent.com/u/379318?v=4)](https://github.com/yunosh "yunosh (220 commits)")[![mrubinsk](https://avatars.githubusercontent.com/u/66822?v=4)](https://github.com/mrubinsk "mrubinsk (189 commits)")[![slusarz](https://avatars.githubusercontent.com/u/381003?v=4)](https://github.com/slusarz "slusarz (33 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (14 commits)")[![renan](https://avatars.githubusercontent.com/u/28046?v=4)](https://github.com/renan "renan (3 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![wrobel](https://avatars.githubusercontent.com/u/10232?v=4)](https://github.com/wrobel "wrobel (2 commits)")[![ralfbecker](https://avatars.githubusercontent.com/u/972180?v=4)](https://github.com/ralfbecker "ralfbecker (2 commits)")[![TDannhauer](https://avatars.githubusercontent.com/u/6716033?v=4)](https://github.com/TDannhauer "TDannhauer (1 commits)")

---

Tags

zipgzipTNEF

### Embed Badge

![Health badge](/badges/horde-compress/health.svg)

```
[![Health](https://phpackages.com/badges/horde-compress/health.svg)](https://phpackages.com/packages/horde-compress)
```

###  Alternatives

[horde/horde

Horde base application

583.0k70](/packages/horde-horde)[horde/imap_client

IMAP client library

275.5k18](/packages/horde-imap-client)[horde/kronolith

Calendar and scheduling application

101.5k4](/packages/horde-kronolith)[horde/imp

Webmail application

261.3k](/packages/horde-imp)

PHPackages © 2026

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