PHPackages                             php-serializer/php-serializer - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. php-serializer/php-serializer

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

php-serializer/php-serializer
=============================

Streaming parser for serialized PHP arrays

0.1(11y ago)29.5k1PHP

Since Feb 23Pushed 11y agoCompare

[ Source](https://github.com/adamnicholson/php-serializer)[ Packagist](https://packagist.org/packages/php-serializer/php-serializer)[ RSS](/packages/php-serializer-php-serializer/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (1)

PHPSerializer
=============

[](#phpserializer)

> This library is a work in progress. Test any builds before `phpunit` before use.

Library for very quick manipulation of large serialized strings,

PHPSerializer was built to improve the efficience of [Flatbase](https://github.com/adamnicholson/flatbase)

In PHP, if you have a serialized array and you wish to add an item to that array, you'd need to do something like this:

```
$data = unserialize($serialized);
array_push($data, 'some-new-item');
$serialized = unserialize($data);

```

What's the problem with this? Well it's extremely inefficient to unserialize that entire array for such a simple operation.

If you're unserializing a small array or you're not doing it very often then this is probably fine, but if you're in a heavy load setup there must be a better way.

The idea behind PHPSerializer is essentially to parse and stream serialized strings in the most efficient way possible depending on the operation, rather than `unserialize()`'ing the entire string for every function.

The speed benefits can be outstanding. Here's some benchmarking results from early testing versions of PHPSerializer using this approach:

```
> Beginning benchmarking test for appending new items to a serialized array
> Benchmarking appends by unserialize(), array_push(), and serialize()
> - Performed 2000 appends to a data set of 10000 in 7.004s, with a memory peack of 5.00Mb
> Benchmarking appends PHPSerializer\SerializeArray::append()
> - Performed 2000 appends to a data set of 10000 in 34ms, with a memory peack of 5.25Mb

```

To re-iterate those results; performing 2,000 array\_push() operations on a serialized array with 10,000 items took `7.004s` with the traditional method, versus a measly `34ms` with PHPSerializer.

Another example where huge speed gains can be made is reading the first item from a serialized array. Normally you would need to `unserialize()` the entire array regardless of how many array elements you're interested in. Let's see what the difference is

```
> Building control data
> Benchmarking reads using PHPSerializer::first()
> - Read the first item from a data set of 3000000 in 89ms, with a memory peack of 2.23Gb
> Benchmarking reads using unserialize[]
> - Read the first item from a data set of 3000000 in 1.118s, with a memory peack of 2.23Gb

```

That's `1250%` faster, dropping from `1.118s` to just `89ms`

Feature wishlist:

- Be able to stream from files directly
- Appending an item to a serialized array (`array_push()`)
- Retreive a single item from a serialized array by its key
- Search for an item in a serialized array by its value (`array_search()`)
- Filter all items in a serialized array (`array_filter()`)
- Strict serialized string validation; `unserialize('b:1;ThisWillNotThrowAnError')`

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4147d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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