PHPackages                             eggbe/compact - 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. eggbe/compact

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

eggbe/compact
=============

Universal object packer and unpacker

1157PHP

Since Aug 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/eggbe/compact)[ Packagist](https://packagist.org/packages/eggbe/compact)[ RSS](/packages/eggbe-compact/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Introduction
------------

[](#introduction)

This is the lightweight and high-performance library provides the simple way to transfer any objects or arrays between two applications.

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

[](#requirements)

- PHP &gt;= 7.2.0
- [Eggbe/Utilities](https://github.com/eggbe/utilities)
- [Able/Helpers](https://github.com/phpable/helpers)
- [Able/Prototype](https://github.com/phpable/prototypes)

Install
-------

[](#install)

Here's the simpler way to install the Eggbe/Compact package via [composer](http://getcomposer.org):

```
composer require eggbe/compact
```

Usage
-----

[](#usage)

Now we can use the library features anywhere in the code:

```
$SerializedDataArray = Compactor::compact($OriginalDataArray, $FlagsCombination);
```

The binary flags combination define the library behavior in contentious cases. Currently only two flags are supported: `Compactor::CO_STRICT` and `Compactor::CO_ALLOW_ARRAYABLE`. The `Compactor::CO_STRICT` flag is always set by default.

In the strict mode the library requires that all objects implement the `\Able\Prototypes\IPresentable` interface defined in the [Able/Prototypes](https://github.com/phpable/prototypes) package. This interface provides an universal way to present an object as an array by the simple implementation of `IPresentable::present()` method.

In other case when the `Compactor::CO_ALLOW_ARRAYABLE` flag is provided and an object don't implement the `\Able\Prototypes\IPresentable` interface then the library tries to convert this object into an array via `toArray()` method. If this method don't exists an exception will be thrown.

The following code is return data back from the serialized representation:

```
$OriginalDataArray = Compactor::decompact($SerializedDataArray, $Aliaser);
```

The library requires that all restorable objects implement the `\Able\Prototypes\IRestorable` interface defined in the [Able/Prototypes](https://github.com/phpable/prototypes) package. This interface provides an universal way to create an object and fill its with data by the simple implementation of `IRestorable` constructor.

Sometimes it's important to make class overloading during the deserialization process. The second parameter of the `Compactor::decompact()` provids the simplest way to do it. Please, see the [Aliaser](https://github.com/eggbe/utilities) component documentation for more information.

License
-------

[](#license)

This package is released under the [MIT license](https://github.com/eggbe/compact/blob/master/LICENSE).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

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://www.gravatar.com/avatar/0e7980486450f7ae6c622ae5499ed59ee231673ebf27f7f18bb204846cd9bf84?d=identicon)[eggbe](/maintainers/eggbe)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/eggbe-compact/health.svg)

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

PHPackages © 2026

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