PHPackages                             northrook/compressor - 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. northrook/compressor

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

northrook/compressor
====================

A PHP compression library.

013PHP

Since Jul 20Pushed 1y agoCompare

[ Source](https://github.com/northrook/compressor)[ Packagist](https://packagist.org/packages/northrook/compressor)[ RSS](/packages/northrook-compressor/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Compressor
==========

[](#compressor)

A lossless data compression library using PHP `zlib`.

Important

This package is still in development.

While it is considered MVP and stable, it may still undergo breaking changes.

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

[](#installation)

```
composer require northrook/compressor
```

Usage
-----

[](#usage)

### Compressing

[](#compressing)

Compress data using the `Compressor::compress()` function, it has two arguments:

- `mixed $data` to compress. It is type-checked, and serialized using the native `\serialize` function if it us not a string,
- `int $level` of compression, from 0 to 9, defaulting to 9.

```
$example = \Northrook\Compressor::compress( $_SERVER ) : Compressor;
$example->data;  // Resulting compressed string
$example->report // "Compressed data array, from 3.54kB to 1.41kB, saving 60.17%."
```

### Decompressing

[](#decompressing)

To decompress the data, use the `decompress` static function, it has two arguments:

- `string $data` to decompress. Unserialized by default.
- `bool $raw` Returns the decompressed data as-is.

```
$server_array = \Northrook\Compressor::decompress( $example ) : mixed;
$server_array //
```

Tip

Greater compression may be achieved by pre-serializing the data in some cases.

Just don't forget to set `decompress( $data, true )`, and apply the appropriate deserializer externally.

Arrays of HTML-like strings typically benefit from using `json_encode`, typically `~2%` smaller than `serialize`.

### Notes

[](#notes)

The `Compressor` class is `\Stringable`, but also provides the readonly `data` property for unambiguous access.

License
-------

[](#license)

[MIT](https://github.com/northrook/compressor/blob/main/LICENSE)

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/60818044?v=4)[Martin](/maintainers/martinlikescoffee)[@martinlikescoffee](https://github.com/martinlikescoffee)

---

Top Contributors

[![martinlikescoffee](https://avatars.githubusercontent.com/u/60818044?v=4)](https://github.com/martinlikescoffee "martinlikescoffee (4 commits)")

### Embed Badge

![Health badge](/badges/northrook-compressor/health.svg)

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

PHPackages © 2026

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