PHPackages                             igbinary/igbinary - 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. igbinary/igbinary

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

igbinary/igbinary
=================

Igbinary is a drop in replacement for the standard php serializer. Instead of the time and space consuming textual representation used by PHP's serialize(), igbinary stores php data structures in a compact binary form. Savings are significant when using memcached or similar memory based storages for serialized data.

3.2.17RC1(5mo ago)7801.7k↑25%73[3 issues](https://github.com/igbinary/igbinary/issues)[4 PRs](https://github.com/igbinary/igbinary/pulls)BSD-3-ClausePHPPHP &gt;= 7.0.0CI passing

Since Nov 26Pushed 5mo ago43 watchersCompare

[ Source](https://github.com/igbinary/igbinary)[ Packagist](https://packagist.org/packages/igbinary/igbinary)[ Docs](https://github.com/igbinary/igbinary)[ RSS](/packages/igbinary-igbinary/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (2)Used By (0)

igbinary
========

[](#igbinary)

[![Build Status](https://github.com/igbinary/igbinary/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/igbinary/igbinary/actions/workflows/main.yml?query=branch%3Amaster)[![Build Status (Windows)](https://camo.githubusercontent.com/a6732fa9529aa2cfb06baa0a98d62cdef820ff4b210bac6b26795e1b2d422c99/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f7375686b6b756d6a317968396467616e3f7376673d74727565)](https://ci.appveyor.com/project/TysonAndre/igbinary-bemsx)

Igbinary is a drop in replacement for the standard php serializer. Instead of the time and space consuming textual representation used by PHP's `serialize`, igbinary stores php data structures in a compact binary form. Memory savings are significant when using memcached, APCu, or similar memory based storages for serialized data. The typical reduction in storage requirements are around 50%. The exact percentage depends on your data.

Unserialization performance is [at least on par with the standard PHP serializer, and is much faster for repetitive data](benchmark/comparisons.php). Serialization performance depends on the `igbinary.compact_strings` option which enables duplicate string tracking. String are inserted to a hash table, which adds some overhead when serializing. In usual scenarios this does not have much of an impact, because the typical usage pattern is "serialize rarely, unserialize often". With the `compact_strings` option enabled, igbinary is usually a bit slower than the standard serializer. Without it, igbinary is a bit faster.

Features
--------

[](#features)

- Support for the same data types as the standard PHP serializer: null, bool, int, float, string, array and object.
- `__autoload` &amp; `unserialize_callback_func`
- `__sleep` &amp; `__wakeup`
- `__serialize` &amp; `__unserialize` (only used in php 7.4+)
- Serializable -interface
- Data portability between platforms (32/64bit, endianness)
- Tested on Linux amd64, Linux ARM, Mac OSX x86, HP-UX PA-RISC and NetBSD sparc64
- Hooks up to the APCu in-memory key-value store as a serialization handler.
- Compatible with 7.0 – 8.0 (The older igbinary [2.x releases](https://github.com/igbinary/igbinary/tree/v2) support 5.2 – 5.6, 7.0 – 7.3)

Implementation details
----------------------

[](#implementation-details)

Storing complex PHP data structures such as arrays of associative arrays with the standard PHP serializer is not very space efficient. The main reasons of this inefficiency are listed below, in order of significance (at least in our applications):

1. Array keys, property names, and class names are repeated redundantly.
2. Numerical values are plain text.
3. Human readability adds some overhead.

Igbinary uses two strategies to minimize the size of the serialized output.

1. Repeated strings are stored only once (this also includes class and property names). Collections of objects benefit significantly from this. See the `igbinary.compact_strings` option.
2. Integer values are stored in the smallest primitive data type available: *123* = `int8_t`, *1234* = `int16_t`, *123456* = `int32_t`... and so on.
3. ( Well, it is not human readable ;)

How to use
----------

[](#how-to-use)

Add the following lines to your php.ini:

```
; Load igbinary extension
extension=igbinary.so

; Use igbinary as session serializer
session.serialize_handler=igbinary

; Enable or disable compacting of duplicate strings
; The default is On.
igbinary.compact_strings=On

; If uncommented, use igbinary as the serializer of APCu
; (APCu 5.1.10 or newer is strongly recommended)
;apc.serializer=igbinary
```

Then, in your php code, replace `serialize` and `unserialize` function calls with [`igbinary_serialize` and `igbinary_unserialize`](./igbinary.php).

Installing
----------

[](#installing)

### Linux

[](#linux)

If PHP was installed through your package manager, the package manager may also contain prebuilt packages for `igbinary`(with a package name similar to php-igbinary).

- The packages from some package managers and OS versions may be out of date and have known bugs. The latest release of igbinary is [![The Latest Stable Version](https://camo.githubusercontent.com/8eef2315469c04909a0ae8db628167f3a55fc2a040998f2b492e1c603a2ee047/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f696762696e6172792f696762696e6172792e737667)](https://github.com/igbinary/igbinary/releases)

Igbinary may also be installed with the command `pecl install igbinary` (You will need to enable igbinary in php.ini)

Alternately, you may wish to [build from source](#building-from-source)

### MacOS

[](#macos)

`pecl install igbinary` is the recommended installation method (You will need to enable igbinary in php.ini)

Alternately, you may wish to [build from source](#building-from-source).

### Installing on Windows

[](#installing-on-windows)

Prebuilt DLLs can be [downloaded from PECL](https://pecl.php.net/package/igbinary).

If you are a contributor to/packager of igbinary, or need to build from source, see [WINDOWS.md](./WINDOWS.md)

### Building from source

[](#building-from-source)

1. `phpize`
2. `./configure`

    - With GCC: `./configure CFLAGS="-O2 -g" --enable-igbinary`
    - With ICC (Intel C Compiler) `./configure CFLAGS=" -no-prec-div -O3 -xO -unroll2 -g" CC=icc --enable-igbinary`
    - With clang: `./configure CC=clang CFLAGS="-O0 -g" --enable-igbinary`
3. `make`
4. `make test`
5. `make install`
6. `igbinary.so` is installed to the default extension directory

Bugs &amp; Contributions
------------------------

[](#bugs--contributions)

Mailing list for bug reports and other development discussion can be found at  (no longer used)

File bug reports at

The preferred way to contribute is with pull requests. Feel free to fork this at

See [TESTING.md](./TESTING.md) for advice for testing patches.

See [TECH\_NOTES.md](./TECH_NOTES.md) for information about how igbinary is implemented

Utilizing in other extensions
-----------------------------

[](#utilizing-in-other-extensions)

Igbinary can be called from other extensions fairly easily. Igbinary installs its header file to *ext/igbinary/igbinary.h*. There are just two straightforward functions: `igbinary_serialize` and `igbinary_unserialize`. Look at *igbinary.h* for prototypes and usage.

Add `PHP_ADD_EXTENSION_DEP(yourextension, igbinary)` to your *config.m4* in case someone wants to compile both of them statically into php.

Trivia
------

[](#trivia)

Where does the name "igbinary" come from? There was once a similar project called fbinary but it has disappeared from the Internet a long time ago. Its architecture wasn't particularly clean either. IG is an abbreviation for a Finnish social networking site IRC-Galleria ()

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance70

Regular maintenance activity

Popularity45

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

173d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19c523bef3a3624a00e7775b4b76b9105e3d3836a8af851079d56b8f49ecff60?d=identicon)[tricky](/maintainers/tricky)

---

Top Contributors

[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (469 commits)")[![tricky](https://avatars.githubusercontent.com/u/91601?v=4)](https://github.com/tricky "tricky (57 commits)")[![phadej](https://avatars.githubusercontent.com/u/51087?v=4)](https://github.com/phadej "phadej (53 commits)")[![tuner](https://avatars.githubusercontent.com/u/399972?v=4)](https://github.com/tuner "tuner (23 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (14 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (13 commits)")[![pierrejoye](https://avatars.githubusercontent.com/u/282408?v=4)](https://github.com/pierrejoye "pierrejoye (12 commits)")[![derickr](https://avatars.githubusercontent.com/u/208074?v=4)](https://github.com/derickr "derickr (3 commits)")[![petk](https://avatars.githubusercontent.com/u/1614009?v=4)](https://github.com/petk "petk (3 commits)")[![dktapps](https://avatars.githubusercontent.com/u/14214667?v=4)](https://github.com/dktapps "dktapps (3 commits)")[![sodabrew](https://avatars.githubusercontent.com/u/39406?v=4)](https://github.com/sodabrew "sodabrew (3 commits)")[![TysonAndre-tmg](https://avatars.githubusercontent.com/u/110992834?v=4)](https://github.com/TysonAndre-tmg "TysonAndre-tmg (2 commits)")[![razvanphp](https://avatars.githubusercontent.com/u/4599319?v=4)](https://github.com/razvanphp "razvanphp (2 commits)")[![andypost](https://avatars.githubusercontent.com/u/73713?v=4)](https://github.com/andypost "andypost (2 commits)")[![jakubsacha](https://avatars.githubusercontent.com/u/2614135?v=4)](https://github.com/jakubsacha "jakubsacha (1 commits)")[![iliaal](https://avatars.githubusercontent.com/u/158724?v=4)](https://github.com/iliaal "iliaal (1 commits)")[![RahimovIR](https://avatars.githubusercontent.com/u/597268?v=4)](https://github.com/RahimovIR "RahimovIR (1 commits)")[![arokettu](https://avatars.githubusercontent.com/u/963485?v=4)](https://github.com/arokettu "arokettu (1 commits)")[![iggyvolz](https://avatars.githubusercontent.com/u/2197376?v=4)](https://github.com/iggyvolz "iggyvolz (1 commits)")[![rlerdorf](https://avatars.githubusercontent.com/u/54641?v=4)](https://github.com/rlerdorf "rlerdorf (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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