PHPackages                             matthiasnoback/broadway-serialization - 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. matthiasnoback/broadway-serialization

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

matthiasnoback/broadway-serialization
=====================================

Serialization helpers for Broadway

v3.0.0(5y ago)29222.0k↑221.4%6[2 PRs](https://github.com/matthiasnoback/broadway-serialization/pulls)1MITPHPPHP ^7.0|^8.0CI failing

Since Jul 7Pushed 5y ago2 watchersCompare

[ Source](https://github.com/matthiasnoback/broadway-serialization)[ Packagist](https://packagist.org/packages/matthiasnoback/broadway-serialization)[ Docs](http://github.com/matthiasnoback/broadway-serialization)[ RSS](/packages/matthiasnoback-broadway-serialization/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (4)Versions (14)Used By (1)

Broadway Serialization helper library
=====================================

[](#broadway-serialization-helper-library)

By Matthias Noback

Event-sourcing framework [Broadway](https://github.com/broadway/broadway)requires a lot of your objects (like domain events and often view models as well) to be serializable because they have to be stored in plain text and later be reconstituted.

Making an object serializable requires you to write lots of pretty simple code. Even though that code is simple, you are likely to make mistakes in it. It's also a bit boring to write. To alleviate the pain, this library helps you to make objects serializable with in a few simple steps.

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

[](#installation)

Just run

```
composer require matthiasnoback/broadway-serialization

```

Conventions
-----------

[](#conventions)

This library is very simple and it *just works* because of a few simple and yet assumptions:

1. Serializable objects have at least one property. Properties can have any kind of scope.
2. Serializable objects implements Broadway's `Serializable` interface.
3. Properties contain scalar values, serializable objects, or arrays of serializable objects.

Example
-------

[](#example)

```
use Broadway\Serializer\Serializable;
use BroadwaySerialization\Serialization\AutoSerializable;

class SerializableObject implements SerializableInterface
{
    use AutoSerializable;

    /**
     * @var string
     */
    private $foo;

    /**
     * @var SerializableObject
     */
    private $bar;

    /**
     * @var SerializableObject[]
     */
    private $bars = [];

    protected static function deserializationCallbacks()
    {
        return [
            'bar' => ['SerializableObject', 'deserialize'],
            'bars' => ['SerializableObject', 'deserialize']
        ];
    }
}
```

By implementing `deserializationCallbacks()` you can define callables that should be called in order to deserialize the provided data. The callable will be called once for single values or multiple times for arrays of values.

Setup
-----

[](#setup)

The `Serializable` trait depends on a little bit of setup. Before calling its `deserialize()` method, make sure you have properly set up a `Reconstitute` service, like this:

```
use BroadwaySerialization\Reconstitution\Reconstitution;
use BroadwaySerialization\Reconstitution\ReconstituteUsingInstantiatorAndHydrator;
use Doctrine\Instantiator\Instantiator;
use BroadwaySerialization\Hydration\HydrateUsingReflection;

Reconstitution::reconstituteUsing(
    new ReconstituteUsingInstantiatorAndHydrator(
        new Instantiator(),
        new HydrateUsingReflection()
    )
);
```

Note that this package ships with different implementations of the hydrator. Depending on your setup and preferences, you can also use the `HydrateUsingClosure` class. The former generally performs better than the `HydrateUsingReflection`.

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

[](#performance)

When using this library, your personal performance will increase significantly. Of course, runtime performance will be worse (not noticeably though, unless you're actually deserializing millions of objects).

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

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

Every ~225 days

Recently: every ~354 days

Total

10

Last Release

1981d ago

Major Versions

v1.2.1 → v2.0.02017-03-15

v2.2.0 → v3.0.02021-01-30

PHP version history (4 changes)v1.0.0PHP &gt;=5.4

v1.1.0PHP &gt;=5.5.9

v2.0.0PHP ^7.0

v3.0.0PHP ^7.0|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1193078?v=4)[Matthias Noback](/maintainers/matthiasnoback)[@matthiasnoback](https://github.com/matthiasnoback)

---

Top Contributors

[![matthiasnoback](https://avatars.githubusercontent.com/u/1193078?v=4)](https://github.com/matthiasnoback "matthiasnoback (25 commits)")[![haampie](https://avatars.githubusercontent.com/u/194764?v=4)](https://github.com/haampie "haampie (7 commits)")[![jdrieghe](https://avatars.githubusercontent.com/u/12606789?v=4)](https://github.com/jdrieghe "jdrieghe (7 commits)")[![MarkRedeman](https://avatars.githubusercontent.com/u/1114829?v=4)](https://github.com/MarkRedeman "MarkRedeman (3 commits)")[![bramdevries](https://avatars.githubusercontent.com/u/1002245?v=4)](https://github.com/bramdevries "bramdevries (2 commits)")[![mbadolato](https://avatars.githubusercontent.com/u/164615?v=4)](https://github.com/mbadolato "mbadolato (1 commits)")

---

Tags

serializationbroadway

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matthiasnoback-broadway-serialization/health.svg)

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

###  Alternatives

[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k234.9M327](/packages/opis-closure)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M680](/packages/jms-serializer-bundle)[google/flatbuffers

FlatBuffers for PHP

26.1k148.3k5](/packages/google-flatbuffers)[apache/avro

Apache Avro™ is a data serialization system.

3.3k60.2k3](/packages/apache-avro)[flix-tech/avro-serde-php

A library to serialize and deserialize Avro records making use of the confluent schema registry

684.2M21](/packages/flix-tech-avro-serde-php)

PHPackages © 2026

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