PHPackages                             better-serializer/better-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. better-serializer/better-serializer

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

better-serializer/better-serializer
===================================

General de/serializer for vatious serialization formats.

0.1.1(8y ago)263.5k21MITPHPPHP ^7.2

Since Jun 25Pushed 5y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (22)Versions (10)Used By (1)

BetterSerializer (PHP)
======================

[](#betterserializer-php)

[![Build Status](https://camo.githubusercontent.com/3a1ebbc7d842cdbc4990cc8dafa17c764d8c0f84f6fd07030662bd4bd012a19d/68747470733a2f2f7472617669732d63692e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/better-serializer/better-serializer)[![Coverage Status](https://camo.githubusercontent.com/5820f2581d1288a5dc6f43bc13d9cee599b2d5198dcaff7dccdffb461794ab68/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/better-serializer/better-serializer?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/124e088c3e96619db5664fca809eddeec7e89882efea787a6b0b2305c3b61d8b/68747470733a2f2f706f7365722e707567782e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f76657273696f6e)](https://packagist.org/packages/better-serializer/better-serializer)[![Total Downloads](https://camo.githubusercontent.com/cd3c0fd0b4a5742616b0539e80a77716b6e41d2eafbef31bdefdd92f6e0f1bbb/68747470733a2f2f706f7365722e707567782e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f646f776e6c6f616473)](https://packagist.org/packages/better-serializer/better-serializer)[![Latest Unstable Version](https://camo.githubusercontent.com/38bff5d6eb5c289084809b6db27d75d690537db4ac660fb8425dd7b2473deac7/68747470733a2f2f706f7365722e707567782e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f762f756e737461626c65)](//packagist.org/packages/better-serializer/better-serializer)[![License](https://camo.githubusercontent.com/8b1ccd2233eae6289192e6e9d16cbbdcff3e15f964e4043090167c1cb314b0cc/68747470733a2f2f706f7365722e707567782e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f6c6963656e7365)](https://packagist.org/packages/better-serializer/better-serializer)[![composer.lock available](https://camo.githubusercontent.com/697c3d91fda287e6f1dd4c74aee3f2b4cf288dffadb006436bc1f268506bbe0d/68747470733a2f2f706f7365722e707567782e6f72672f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65722f636f6d706f7365726c6f636b)](https://packagist.org/packages/better-serializer/better-serializer)[![Appveyor status](https://camo.githubusercontent.com/ae143903514572d0740d5d66ec61ac3a42657d7d451f6fea7f635d413a409b2c/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f6769746875622f6265747465722d73657269616c697a65722f6265747465722d73657269616c697a65723f7376673d74727565)](https://ci.appveyor.com/api/projects/status/github/better-serializer/better-serializer)

This library provides a general serializer for PHP. Currently only JSON serialization format is supported. The project aims to be an alternative to [JmsSerializer](https://github.com/schmittjoh/serializer). It tries to be faster then JmsSerializer and it also tries to sustain a better maintainable and understandable code base. Also, as this is also a learning experiment, one of the goals is to have unit tests with 100% code coverage.

Except the above mentioned goals, the project also aims to provide some cool features - it tries to combine the best features from JmsSerializer and from [Jackson](https://github.com/FasterXML/jackson) in Java.

Current state
-------------

[](#current-state)

Currently, only JSON de/serialization is implemented. It's possible to de/serialize complex nested data structures (objects and arrays). Only arrays are supported as collection types for now.

Performance
-----------

[](#performance)

For now the code is only a proof of concept, but it is stabilizing more and more each day. It already yields interesting results. Without implementing metadata caching, the serialization process is already [4-6x faster](tests/Performance/Serialization/JsonTest.php) than using JmsSerializer. The deserialization process is also faster, but only [cca 3.5x faster](tests/Performance/Deserialization/JsonTest.php).

There is also another benchmark, which compares JMS Serializer, [Ivory Serializer](https://github.com/egeloen/ivory-serializer) and Better Serialier. It also integrates Symfony serializer, but I needed to comment it out, because it was 100-300x slower than Better Serializer. You can find a fork of it [here](https://github.com/better-serializer/ivory-serializer-benchmark) and try it on your own. For best results, please disable XDebug while running the tests.

Here are some of the results:

```
$ php bin/benchmark  --iteration 1000 --horizontal-complexity 2 --vertical-complexity 2
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 0.001188s      | 1.00x  |
| Ivory            | 0.002222s      | 1.87x  |
| JMS              | 0.002901s      | 2.44x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 100 --horizontal-complexity 10 --vertical-complexity 10
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 0.011377s      | 1.00x  |
| Ivory            | 0.037377s      | 3.29x  |
| JMS              | 0.046837s      | 4.12x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 1 --horizontal-complexity 100 --vertical-complexity 200
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 1.040695s      | 1.00x  |
| Ivory            | 4.191479s      | 4.03x  |
| JMS              | 4.466160s      | 4.29x  |
+------------------+----------------+--------+

$ php bin/benchmark  --iteration 1 --horizontal-complexity 200 --vertical-complexity 200
Ivory: Done!
JMS: Done!
BetterSerializer: Done!

+------------------+----------------+--------+
| Serializer       | Duration (sec) | Factor |
+------------------+----------------+--------+
| BetterSerializer | 4.523851s      | 1.00x  |
| Ivory            | 15.580491s     | 3.44x  |
| JMS              | 18.571867s     | 4.11x  |
+------------------+----------------+--------+
```

**This means that you can now effectively de/serialize 4x more entities (e.g. in API results) using the same amount of time than before!**

Regarding the performance gains - I'd like someone to check the measured values, since the results seem quite great and I'm suspicious myself :).

Features
--------

[](#features)

You can check out the features in the [features page](doc/Features.md). Please also check the supported [annotations documentation](doc/Annotations.md).

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

[](#requirements)

This library requires PHP 7.2 and it won't work with older versions. Older versions won't be supported.

Usage
-----

[](#usage)

The usage is described [here](doc/Usage.md).

The de/serializaton annotations are described [here](doc/Annotations.md).

If you'd like to write custom extensions for special de/serialising of selected data types, check the [extensions section](doc/Extensions.md)

Future Plans
------------

[](#future-plans)

- metadata caching
- XML and YAML support
- various collection classes support (Doctrine collections, internal PHP collections like SplStack)
- data injection using class constructors (internal and static), which should improve performance even more
- various features import from JmsSerializer and Jackson
- framework integrations

**Contributions are welcome! :)**

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

Every ~48 days

Recently: every ~63 days

Total

8

Last Release

2954d ago

PHP version history (2 changes)0.0.1PHP ^7.1

0.1.0PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![Rastusik](https://avatars.githubusercontent.com/u/1735097?v=4)](https://github.com/Rastusik "Rastusik (158 commits)")[![eduardor2k](https://avatars.githubusercontent.com/u/318278?v=4)](https://github.com/eduardor2k "eduardor2k (1 commits)")

---

Tags

annotationsdeserializationfastjacksonjsonphpphp71serializer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M465](/packages/pimcore-pimcore)[akeneo/pim-community-dev

Akeneo PIM, the future of catalog management is open!

1.0k624.1k86](/packages/akeneo-pim-community-dev)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[oro/platform

Business Application Platform (BAP)

642140.7k105](/packages/oro-platform)[oat-sa/tao-core

TAO core extension

66140.1k108](/packages/oat-sa-tao-core)

PHPackages © 2026

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