PHPackages                             bernard/normalt - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bernard/normalt

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bernard/normalt
===============

Normalt is a extension to Symfony Serializer that only implements the Normalization part

v1.2.0(8y ago)221.5M↑91.6%9[2 PRs](https://github.com/bernardphp/normalt/pulls)1MITPHPPHP ^5.6||^7.0

Since Mar 1Pushed 4y ago4 watchersCompare

[ Source](https://github.com/bernardphp/normalt)[ Packagist](https://packagist.org/packages/bernard/normalt)[ RSS](/packages/bernard-normalt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (1)

Normalt
=======

[](#normalt)

[![Build Status](https://camo.githubusercontent.com/b73bf178bb44e367e032480565aee8b453a5e0c0f66022596a176e5d82d2365a/68747470733a2f2f7472617669732d63692e6f72672f6265726e6172647068702f6e6f726d616c742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/bernardphp/normalt)

Normalt contains additional normalizers for use with the serializer component found in Symfony. It also implements a normalizer delegator that will look at the data you want normalized and/or denormalized and call the normalizer which supports it.

In the context of Normalt normalization is the act of converting an object into an array. Denormalization is the opposite direction (converting array into an object). This is to my knowledge the same concept Symfony serializer uses.

Table of Contents
-----------------

[](#table-of-contents)

- [Getting Started](#getting-started)
- [Normalizers](#normalizers)
    - [AggregateNormalizer](#aggregatenormalizer)
    - [DoctrineNormalizer](#doctrinenormalizer)
    - [RecursiveReflectionNormalizer](#recursivereflectionnormalizer)
- [License](#license)

Getting Started
---------------

[](#getting-started)

Getting started is as easy as requiring the library with composer.

```
$ composer require bernard/normalt
```

Normalizers
-----------

[](#normalizers)

Theese normalizers can be used with the serializer component directly or through the `AggregateNormalizer`.

### AggregateNormalizer

[](#aggregatenormalizer)

`AggregateNormalizer` is a delegator and aggregator as it aggregates multiple normalizers and denormalizers which it will delegate the process to.

It have a list of normalizers and denormalizers. It will ask each of theese if they support the data/object and use the first found.

It implements a subset of the full serializer and its only focus is normalizing to arrays and denormalize arrays into objects. This lets you focus on normalization instead of converting into a specific format such as `xml`, `json` etc.

#### Usage

[](#usage)

You need to instantiate the normalizer and the list of normalizer/denormalizers you want to use. For this example we use `GetSetMethodNormalizer` which is distributed with the symfony package.

This is the class we are going to use. `GetSetMethodNormalizer` uses getters and setters to do its job.

```
class User
{
    protected $name;

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }
}
```

Lets normalize and denormalize it again.

```
use Normalt\Normalizer\AggregateNormalizer;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;

$aggregate = new AggregateNormalizer([new GetSetMethodNormalizer]);

$user = new User;
$user->setName('henrik');

$array = $aggregate->normalize($user);

// $array now contains ['name' => 'henrik']

$user = $aggregate->denormalize($array, 'User');
echo $user->getName(); // outputs Henrik
```

In contrast to the other normalizers in this package, it does **not** make sense to use this with the serializer as the Serializer already does most of the functionality already.

### DoctrineNormalizer

[](#doctrinenormalizer)

`DoctrineNormalizer` normalizes mapped objects (Entities, Documents etc.) into arrays and back again.

It usage is very simple. The following example assume a mapped object of `$user` and that you are using the doctrine orm (other doctrine projects work aswell!).

```
use Doctrine\ORM\EntityManager;
use Normalt\Normalizer\DoctrineNormalizer;

// create $entityManager
$normalizer = new DoctrineNormalizer($entityManager);

// assuming $user is a mapped object and have the identifier value of 10. the following will return
// array('MyModel\User', 10)
$array = $normalizer->normalize($user);

// using the same structure you can convert it back into a user
$user = $normalizer->denormalize($array, null);
```

### RecursiveReflectionNormalizer

[](#recursivereflectionnormalizer)

This normalizes also delegates like the `AggregateNormalizer`, but delegates for each property in the object you are normalizing to normalize. It does this with recursion, so if a normalizer does not support a given property and is an array it will loop through that array and look for more objects.

The same thing happens when denormalizing, except it will try and find a supporting denormalizer for the property structure before looping.

Using is simple as the other, the example utilises `DoctrineNormalizer` and assumes we have a `$profile` object that contains a reference to a user with `$profile->user`.

```
use Normalt\Normalizer\RecursiveReflectionNormalizer;
use Normalt\Normalizer\DoctrineNormalizer;

$normalizer = new RecursiveReflectionNormalizer([new DoctrineNormalizer($entityManager)]);

// following will return assuming User is mapped and has the identifier of 10
//['user' => ['MyModel\User', 10]]
$array = $normalizer->normalize($profile);

// converting it back into the object.
// $profile->user is now an instance of MyModel\User
$profile = $normalize->denormalize($array, 'MyModel\Profile');
```

License
-------

[](#license)

Please refer to the included `LICENSE` file.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 81.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 ~282 days

Recently: every ~352 days

Total

6

Last Release

3047d ago

Major Versions

0.2.0 → 1.0.02014-03-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/88caaddb9c765141dba5816fbb2f8a5ed8e2125338b97e30261e19bb88cdaa23?d=identicon)[henrikbjorn](/maintainers/henrikbjorn)

---

Top Contributors

[![henrikbjorn](https://avatars.githubusercontent.com/u/19725?v=4)](https://github.com/henrikbjorn "henrikbjorn (36 commits)")[![sagikazarmark](https://avatars.githubusercontent.com/u/1226384?v=4)](https://github.com/sagikazarmark "sagikazarmark (3 commits)")[![acrobat](https://avatars.githubusercontent.com/u/1374857?v=4)](https://github.com/acrobat "acrobat (2 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (1 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (1 commits)")[![stephanedelprat](https://avatars.githubusercontent.com/u/152964289?v=4)](https://github.com/stephanedelprat "stephanedelprat (1 commits)")

---

Tags

normalizationdenormalization

### Embed Badge

![Health badge](/badges/bernard-normalt/health.svg)

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

###  Alternatives

[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[symfony/ai-agent

PHP library for building agentic applications.

30536.7k44](/packages/symfony-ai-agent)[morrislaptop/laravel-popo-caster

Automatically cast JSON columns to rich PHP objects in Laravel using Symfony's Serializer

27643.8k](/packages/morrislaptop-laravel-popo-caster)

PHPackages © 2026

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