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

ActiveSymfony-bundle

mrgoodbytes8667/enum-serializer-bundle
======================================

A bundle to enable spatie/enum Serialization support in Symfony

v5.0.2(1y ago)097.8k↓50%7CC-BY-NC-4.0PHPPHP ^8.1CI passing

Since Oct 22Pushed 9mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (11)Versions (68)Used By (7)

enum-serializer-bundle
======================

[](#enum-serializer-bundle)

[![Packagist Version](https://camo.githubusercontent.com/dc28136b2cf4f90a5b0091976b2c309d7a0901abf7736d9305b326331db7ed00/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c653f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://packagist.org/packages/mrgoodbytes8667/enum-serializer-bundle)[![PHP from Packagist](https://camo.githubusercontent.com/9b327eb54b63fa4baf7402debe8408e8c0f4ff1b4d610c23b5f6e1201d61f9eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c653f6c6f676f3d706870266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://packagist.org/packages/mrgoodbytes8667/enum-serializer-bundle)[![Symfony Versions Supported](https://camo.githubusercontent.com/12deed934c05c1bb714223df06b75c09888095b3c2e133b0eeac16983412fb91/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c6425324673796d666f6e792532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/12deed934c05c1bb714223df06b75c09888095b3c2e133b0eeac16983412fb91/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c6425324673796d666f6e792532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)[![Symfony Versions Tested](https://camo.githubusercontent.com/0edd8b706c5dcc1a7d5efb075a320d1b0a67e63504a43f4c0b2029015146d631/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c6425324673796d666f6e792d7465737425324625323533452532353344362e3325323532302532353343372e33266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/0edd8b706c5dcc1a7d5efb075a320d1b0a67e63504a43f4c0b2029015146d631/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c6425324673796d666f6e792d7465737425324625323533452532353344362e3325323532302532353343372e33266c6f676f436f6c6f723d464646267374796c653d666c6174)[![Symfony LTS Version](https://camo.githubusercontent.com/7358acaf33ac4f4fd1e2f4eef967521c7c8f1ca60ad525e3a480008fa86f5fad/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c642532466c74732532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/7358acaf33ac4f4fd1e2f4eef967521c7c8f1ca60ad525e3a480008fa86f5fad/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c642532466c74732532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)[![Symfony Stable Version](https://camo.githubusercontent.com/e6d2d692803518473353a477cd1b9d839908e4b5c93d4c46dccd35bc8eb733ac/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c64253246737461626c652532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/e6d2d692803518473353a477cd1b9d839908e4b5c93d4c46dccd35bc8eb733ac/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c64253246737461626c652532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)[![Symfony Dev Version](https://camo.githubusercontent.com/aa428a05bfd3e5278e8a79b29ec478dc919b2dda5cda79a2845895e6f4854843/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c642532466465762532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/aa428a05bfd3e5278e8a79b29ec478dc919b2dda5cda79a2845895e6f4854843/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246736869656c64732e6d72676f6f6462797465732e646576253246736869656c642532466465762532462532353545362e332532353230253235374325323532302532353545372e30266c6f676f436f6c6f723d464646267374796c653d666c6174)[![Packagist License](https://camo.githubusercontent.com/806745bc3c399e9807630474a9d2519248bf66beffcc1b6389774b3b7028aad8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c653f6c6f676f3d63726561746976652d636f6d6d6f6e73266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/806745bc3c399e9807630474a9d2519248bf66beffcc1b6389774b3b7028aad8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c653f6c6f676f3d63726561746976652d636f6d6d6f6e73266c6f676f436f6c6f723d464646267374796c653d666c6174)[![GitHub Release Workflow Status](https://camo.githubusercontent.com/7e27363cbb000e3c31ea0f3dfd3203e509febc8490c496d7d922f7678e21aa3d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72656c656173652e796d6c3f6c6162656c3d737461626c652532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/7e27363cbb000e3c31ea0f3dfd3203e509febc8490c496d7d922f7678e21aa3d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72656c656173652e796d6c3f6c6162656c3d737461626c652532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)[![GitHub Tests Workflow Status](https://camo.githubusercontent.com/c10c111c2d9b4b38d4717a1b7365c1c18f933d1eff86cc68a4dab39fc32574e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72756e2d74657374732e796d6c3f6c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/c10c111c2d9b4b38d4717a1b7365c1c18f933d1eff86cc68a4dab39fc32574e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72756e2d74657374732e796d6c3f6c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)[![GitHub By Version Workflow Status](https://camo.githubusercontent.com/277d0781f024973227c8eaa80ee5c620707ce3152fdc21558c9cb9a022d8bb04/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72756e2d74657374732d62792d76657273696f6e2e796d6c3f6c6162656c3d62792d76657273696f6e2532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/277d0781f024973227c8eaa80ee5c620707ce3152fdc21558c9cb9a022d8bb04/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f72756e2d74657374732d62792d76657273696f6e2e796d6c3f6c6162656c3d62792d76657273696f6e2532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)[![GitHub Coverage Workflow Status](https://camo.githubusercontent.com/513d49621818394d0eebd2c2ceba74921321c989e072f1383f7139f40727db20/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f636f64652d636f7665726167652e796d6c3f6c6162656c3d636f7665726167652532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://camo.githubusercontent.com/513d49621818394d0eebd2c2ceba74921321c989e072f1383f7139f40727db20/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f636f64652d636f7665726167652e796d6c3f6c6162656c3d636f7665726167652532306275696c64266c6f676f3d676974687562266c6f676f436f6c6f723d464646267374796c653d666c6174)[![codecov](https://camo.githubusercontent.com/887399fad432a9af4ee70e9ed75015cce5df26d2f32ca626055bc64a8be34aa4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d72676f6f646279746573383636372f656e756d2d73657269616c697a65722d62756e646c652f362e303f6c6f676f3d636f6465636f76266c6f676f436f6c6f723d464646267374796c653d666c6174)](https://codecov.io/gh/mrgoodbytes8667/enum-serializer-bundle)
A bundle to provide some helper methods for PHP 8.1+ enums inspired by [spatie/enum](https://github.com/spatie/enum)

Upgrading to 6.0 from 5.x
-------------------------

[](#upgrading-to-60-from-5x)

- The EnumNormalizer will no longer be registered as a service by default. You must manually enable it to continue using it. It will be removed in v7.

Upgrading to 4.0 from 3.x
-------------------------

[](#upgrading-to-40-from-3x)

- Replace any usages of `Bytes\EnumSerializerBundle\Request\EnumParameterConverter` with ValueResolvers. See [https://symfony.com/doc/current/controller/value\_resolver.html](https://symfony.com/doc/current/controller/value_resolver.html)

Upgrading to 3.0 from 2.x
-------------------------

[](#upgrading-to-30-from-2x)

- Replace the deprecated calls to `easyAdminChoices()` and `formChoices()` with `provideFormChoices()`.
- Upgrade any overridden versions of `provideFormChoices()`, `getFormChoiceKey()`, and `getFormChoiceValue()` from `protected` to `public`.

Upgrading to 2.0
----------------

[](#upgrading-to-20)

Change all classes that extend `Bytes\EnumSerializerBundle\Enums\Enum` to be string backed enums, using the new `Bytes\EnumSerializerBundle\Enums\StringBackedEnumTrait` trait and implementing the new `Bytes\EnumSerializerBundle\Enums\StringBackedEnumInterface` interface.

- `Bytes\EnumSerializerBundle\Enums\StringBackedEnumTrait` provides the previous `Enum` class methods that are still relevant and needed with the switch to enums, including a `jsonSerializable()` method to keep serialization consistent.
- `Bytes\EnumSerializerBundle\Enums\StringBackedEnumInterface` must be implemented (or `\JsonSerializable`) in order to have the serializer properly return label/value as it did prior to 2.0.
- Note: `Bytes\EnumSerializerBundle\Enums\StringBackedEnumInterface` extends both `Bytes\EnumSerializerBundle\Enums\EasyAdminChoiceEnumInterface` and `Bytes\EnumSerializerBundle\Enums\FormChoiceEnumInterface`, which both automatically provide EasyAdminBundle and Symfony form compatible choice methods and are easily overloadable.

### Before

[](#before)

```
