PHPackages                             aboutcoders/enum-serializer-bundle - 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. aboutcoders/enum-serializer-bundle

ActiveSymfony-bundle[Parsing &amp; Serialization](/categories/parsing)

aboutcoders/enum-serializer-bundle
==================================

A symfony bundle to serialize/deserialize enumerations of type myclabs/php-enum with jms/serializer

0.4.0(5y ago)427.4k↓45.5%5[1 issues](https://github.com/aboutcoders/enum-serializer-bundle/issues)1MITPHPPHP &gt;=7.1.0CI failing

Since May 15Pushed 5y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (9)Used By (1)

AbcEnumSerializerBundle
=======================

[](#abcenumserializerbundle)

A symfony bundle to serialize/deserialize enumerations of type [myclabs/php-enum](https://github.com/myclabs/php-enum) with [jms/serializer](https://github.com/schmittjoh/serializer).

Build Status: [![Build Status](https://camo.githubusercontent.com/bb96c6f8545996857f43c18c2577c296946b9b4aacdac37ef5c2870b02042394/68747470733a2f2f7472617669732d63692e6f72672f61626f7574636f646572732f656e756d2d73657269616c697a65722d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aboutcoders/enum-serializer-bundle)

**Note: At this point `json` is the only supported format.**

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

[](#installation)

Add the AbcEnumSerializerBundle to your `composer.json` file:

```
php composer.phar require aboutcoders/enum-serializer-bundle

```

Include the bundle in the AppKernel.php class:

```
# app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new Abc\Bundle\EnumSerializerBundle\AbcEnumSerializerBundle(),
    );
}
```

Usage
-----

[](#usage)

Define the enum as defined by [myclabs/php-enum](https://github.com/myclabs/php-enum):

```
namespace Acme;

use MyCLabs\Enum\Enum;

class MyEnum
{
    const VALUE_1;
    const VALUE_2;
}
```

In order to serialize/deserialize the enumeration you can register the type in app/config.yml

```
# app/config/config.yml
abc_enum_serializer:
    serializer:
        types:
            - Acme\MyEnum
```

or you can register the enum within the service container and tag it with with the tag `abc.enum`

```
services:
    my_enum:
        class: Acme\MyEnum
        tags:
            - { name: abc.enum }
```

**Note, this service should be declared private and should never be instantiated, since this would lead to an exception. The only purpose of this service is to provide the fully qualified name of the class that needs to be registered as enum type.**

Finally you can configure the type in case you use it as a member variable

```
use JMS\Serializer\Annotation\Type;

class MyExample
{

    /**
     * @Type("Acme\MyEnum")
     */
    private $myEnum;

}
```

or serialize/deserialize it directly referencing the type:

```
$serializer = $container->get('jms_serializer');

$data = $serializer->serialize($subject, 'json');

$enum = $this->serializer->deserialize($data, MyExample::class, 'json');
```

ToDo
----

[](#todo)

- Add support for the formats XML and YAML

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~256 days

Recently: every ~94 days

Total

8

Last Release

1860d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

0.3.2PHP &gt;=7.1.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11329553?v=4)[AboutCoders](/maintainers/aboutcoders)[@aboutcoders](https://github.com/aboutcoders)

---

Top Contributors

[![hrba](https://avatars.githubusercontent.com/u/2995275?v=4)](https://github.com/hrba "hrba (15 commits)")[![enumag](https://avatars.githubusercontent.com/u/539462?v=4)](https://github.com/enumag "enumag (1 commits)")

---

Tags

enumserializeserializerjmsphp-enumdeserialize

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aboutcoders-enum-serializer-bundle/health.svg)

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

###  Alternatives

[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M37](/packages/goetas-webservices-xsd2php)[goetas-webservices/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

4910.9M36](/packages/goetas-webservices-xsd2php-runtime)[zumba/json-serializer

Serialize PHP variables, including objects, in JSON format. Support to unserialize it too.

129743.7k13](/packages/zumba-json-serializer)[jdesrosiers/silex-jms-serializer-provider

A silex service provider that integrates jms/serializer into silex

11126.3k2](/packages/jdesrosiers-silex-jms-serializer-provider)

PHPackages © 2026

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