PHPackages                             wikibase/internal-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. wikibase/internal-serialization

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

wikibase/internal-serialization
===============================

Serializers and deserializers for the data access layer of Wikibase Repository

2.10.0(6y ago)6155.5k1GPL-2.0-or-laterPHPPHP ^7.0CI failing

Since May 27Pushed 1y ago24 watchersCompare

[ Source](https://github.com/wmde/WikibaseInternalSerialization)[ Packagist](https://packagist.org/packages/wikibase/internal-serialization)[ Docs](https://github.com/wmde/WikibaseInternalSerialization)[ RSS](/packages/wikibase-internal-serialization/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (10)Versions (24)Used By (0)

Wikibase Internal Serialization
===============================

[](#wikibase-internal-serialization)

Library containing serializers and deserializers for the data access layer of [Wikibase](http://wikiba.se/) Repository.

[![Build Status](https://github.com/wmde/WikibaseInternalSerialization/actions/workflows/lint-and-test.yaml/badge.svg?branch=master)](https://github.com/wmde/WikibaseInternalSerialization/actions/workflows/lint-and-test.yaml)

On [Packagist](https://packagist.org/packages/wikibase/internal-serialization): [![Latest Stable Version](https://camo.githubusercontent.com/73a9d761412692053b06f709258ef34809e525e7ae2caf51f5a85f9e35e5ae5b/68747470733a2f2f706f7365722e707567782e6f72672f77696b69626173652f696e7465726e616c2d73657269616c697a6174696f6e2f76657273696f6e2e706e67)](https://packagist.org/packages/wikibase/internal-serialization)[![Download count](https://camo.githubusercontent.com/adb088ab7004aabb1985edbf1b6f166d422e4b319505d15e7e8e63b61ce37d4d/68747470733a2f2f706f7365722e707567782e6f72672f77696b69626173652f696e7465726e616c2d73657269616c697a6174696f6e2f642f746f74616c2e706e67)](https://packagist.org/packages/wikibase/internal-serialization)

Note that this repository is a mirror of part of the upstream [Wikibase project](https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/refs/heads/master/lib/packages/wikibase/internal-serialization/) on Gerrit. Contributions should be made to the directories there using MediaWiki's [Gerrit process](https://www.mediawiki.org/wiki/Gerrit).

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

[](#installation)

The recommended way to use this library is via [Composer](http://getcomposer.org/).

### Composer

[](#composer)

To add this package as a local, per-project dependency to your project, simply add a dependency on `wikibase/internal-serialization` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on version 2.x of this package:

```
{
    "require": {
        "wikibase/internal-serialization": "~2.0"
    }
}

```

### Manual

[](#manual)

Get the code of this package, either via git, or some other means. Also get all dependencies. You can find a list of the dependencies in the "require" section of the composer.json file. Then take care of autoloading the classes defined in the src directory.

Library usage
-------------

[](#library-usage)

Construct an instance of the deserializer or serializer you need via the appropriate factory.

```
use Wikibase\InternalSerialization\DeserializerFactory;

$deserializerFactory = new DeserializerFactory( /* ... */ );
$entityDeserializer = $deserializerFactory->newEntityDeserializer();
```

The use the deserialize or serialize method.

```
$entity = $entityDeserializer->deserialize( $myEntitySerialization );
```

In case of deserialization, guarding against failures is good practice. So it is typically better to use the slightly more verbose try-catch approach.

```
try {
	$entity = $entityDeserializer->deserialize( $myEntitySerialization );
}
catch ( DeserializationException $ex ) {
	// Handling of the exception
}
```

All access to services provided by this library should happen through the `SerializerFactory` and `DeserializerFactory`. The rest of the code is an implementation detail which users are not allowed to know about.

Library structure
-----------------

[](#library-structure)

The Wikibase DataModel objects can all be serialized to a generic format from which the objects can later be reconstructed. This is done via a set of `Serializers\Serializer` implementing objects. These objects turn for instance a `Claim` object into a data structure containing only primitive types and arrays. This data structure can thus be readily fed to `json_encode`, `serialize`, or the like. The process of reconstructing the objects from such a serialization is provided by objects implementing the `Deserializers\Deserializer` interface.

Serializers can be obtained via an instance of `SerializerFactory` and deserializers can be obtained via an instance of `DeserializerFactory`. You are not allowed to construct these serializers and deserializers directly yourself or to have any kind of knowledge of them (ie type hinting). These objects are internal to this serialization and might change name or structure at any time. All you are allowed to know when calling `$serializerFactory->newEntitySerializer()` is that you get back an instance of `Serializers\Serializer`.

The library contains deserializers that handle the legacy internal serialization format. Those can be found in `Wikibase\InternalSerialization\Deserializers`, and all start with the word "Legacy". The remaining deserializers in this namespace are not specific to any format. They detect the one that is used and forward to the appropriate deserializer. These deserializers can thus deal with serializations in the old legacy format and those in the new one.

The `DeserializerFactory` only returns deserializers that can deal with both the legacy and the new format.

Tests
-----

[](#tests)

This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run via TravisCI, as a TravisCI configuration file is also provided in the root directory.

Contributing
------------

[](#contributing)

This repository is a mirror of part of the upstream [Wikibase project](https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/refs/heads/master/lib/packages/wikibase/internal-serialization/) on Gerrit. Contributions should be made to the directories there using MediaWiki's [Gerrit process](https://www.mediawiki.org/wiki/Gerrit).

Authors
-------

[](#authors)

Wikibase Internal Serialization has been written by [Jeroen De Dauw](https://entropywins.wtf/), partially as [Wikimedia Germany](https://wikimedia.de/en) employee for the [Wikidata project](https://wikidata.org/).

Links
-----

[](#links)

- [Wikibase Internal Serialization on Packagist](https://packagist.org/packages/wikibase/internal-serialization)
- [Wikibase Internal Serialization on OpenHub](https://www.openhub.net/p/WikibaseInternalSerialization)

See also
--------

[](#see-also)

- [Wikibase DataModel](https://github.com/wmde/WikibaseDataModel)
- [Wikibase DataModel Serialization](https://github.com/wmde/WikibaseDataModelSerialization) (For the public serialization format)
- [Ask Serialization](https://github.com/wmde/AskSerialization)

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community28

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~114 days

Recently: every ~214 days

Total

19

Last Release

2350d ago

Major Versions

1.5.0 → 2.0.02015-08-31

PHP version history (4 changes)1.0PHP &gt;=5.3.0

2.5.0PHP &gt;=5.5.9

2.8.0PHP &gt;=5.6

2.10.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/451bd4039d530fed8f9c3da91bfa519233a397d2182cdfdcad700f6cfea19b7f?d=identicon)[Jeroen De Dauw](/maintainers/Jeroen%20De%20Dauw)

![](https://www.gravatar.com/avatar/054adb441e7ee248ec924bc45fa793835c284710eb31627587fa5de21bab9e96?d=identicon)[wmde](/maintainers/wmde)

![](https://www.gravatar.com/avatar/5406ed1d40d50ffc61d67e9f5149914dbfe0b8a52bdf297299f5ccfab0a73d91?d=identicon)[thiemowmde](/maintainers/thiemowmde)

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

![](https://www.gravatar.com/avatar/8cc7ef1a982b9520bbe19e7699556cda12f528e2fcece72d0d18e79b6457794c?d=identicon)[mariushoch](/maintainers/mariushoch)

---

Top Contributors

[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (180 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (71 commits)")[![addshore](https://avatars.githubusercontent.com/u/3308769?v=4)](https://github.com/addshore "addshore (41 commits)")[![Benestar](https://avatars.githubusercontent.com/u/2998254?v=4)](https://github.com/Benestar "Benestar (30 commits)")[![mariushoch](https://avatars.githubusercontent.com/u/2446964?v=4)](https://github.com/mariushoch "mariushoch (15 commits)")[![lucaswerkmeister](https://avatars.githubusercontent.com/u/2346599?v=4)](https://github.com/lucaswerkmeister "lucaswerkmeister (8 commits)")[![tobijat](https://avatars.githubusercontent.com/u/2997252?v=4)](https://github.com/tobijat "tobijat (8 commits)")[![manicki](https://avatars.githubusercontent.com/u/3524114?v=4)](https://github.com/manicki "manicki (6 commits)")[![Ladsgroup](https://avatars.githubusercontent.com/u/5351225?v=4)](https://github.com/Ladsgroup "Ladsgroup (6 commits)")[![JanZerebecki](https://avatars.githubusercontent.com/u/7452727?v=4)](https://github.com/JanZerebecki "JanZerebecki (6 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (6 commits)")[![rosalieper](https://avatars.githubusercontent.com/u/15235452?v=4)](https://github.com/rosalieper "rosalieper (5 commits)")[![tarrow](https://avatars.githubusercontent.com/u/7353563?v=4)](https://github.com/tarrow "tarrow (2 commits)")[![JonasKress](https://avatars.githubusercontent.com/u/13198391?v=4)](https://github.com/JonasKress "JonasKress (2 commits)")[![bereket-WMDE](https://avatars.githubusercontent.com/u/71328938?v=4)](https://github.com/bereket-WMDE "bereket-WMDE (2 commits)")[![ZabeMath](https://avatars.githubusercontent.com/u/35405030?v=4)](https://github.com/ZabeMath "ZabeMath (2 commits)")[![filbertkm](https://avatars.githubusercontent.com/u/135401?v=4)](https://github.com/filbertkm "filbertkm (2 commits)")[![codders](https://avatars.githubusercontent.com/u/17782?v=4)](https://github.com/codders "codders (2 commits)")[![itamargiv](https://avatars.githubusercontent.com/u/6132917?v=4)](https://github.com/itamargiv "itamargiv (1 commits)")[![frimelle](https://avatars.githubusercontent.com/u/2714560?v=4)](https://github.com/frimelle "frimelle (1 commits)")

---

Tags

serializationserializerswikidatawikibasedeserializersDataModel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikibase-internal-serialization/health.svg)

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

###  Alternatives

[wikibase/data-model-serialization

Serializers and deserializers for the Wikibase DataModel

10197.4k8](/packages/wikibase-data-model-serialization)[opis/closure

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

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

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

2.3k141.9M921](/packages/jms-serializer)[jms/serializer-bundle

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

1.8k92.4M675](/packages/jms-serializer-bundle)[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)
