PHPackages                             nwidart/laravel-normalizer - 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. [Database &amp; ORM](/categories/database)
4. /
5. nwidart/laravel-normalizer

ActiveLibrary[Database &amp; ORM](/categories/database)

nwidart/laravel-normalizer
==========================

Laravel package to normalize your data before saving into the database.

0.2(10y ago)12552MITPHPPHP ^7.0

Since Jul 26Pushed 10y ago1 watchersCompare

[ Source](https://github.com/nWidart/laravel-normalizer)[ Packagist](https://packagist.org/packages/nwidart/laravel-normalizer)[ Docs](https://github.com/nwidart/laravel-normalizer)[ RSS](/packages/nwidart-laravel-normalizer/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

laravel-normalizer
==================

[](#laravel-normalizer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bd9f432654047fda707e6f8f2b86e36a9585800bf0cf2b1cb49831a08e4e8acc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e7769646172742f6c61726176656c2d6e6f726d616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nwidart/laravel-normalizer)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/d137ae7581b89495b7c64fd5f8709b46bf4964c477a0be68ea629166459fed76/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e5769646172742f6c61726176656c2d6e6f726d616c697a65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/nWidart/laravel-normalizer)[![Scrutinizer Coverage](https://camo.githubusercontent.com/96f2573a5bf1b62fbf2eec99a83a721d9f631dec386cdf4e12a1a38a80586f5f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6e5769646172742f6c61726176656c2d6e6f726d616c697a65722e7376673f6d61784167653d3836343030267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/nWidart/laravel-normalizer/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/d02105b2fdd4a2af41c25d9ee4bf1ce63275de89ebd7f88074504d2a1652ec9d/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f30646531636164392d656361392d343930372d393436362d6434623934336162353138332e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/0de1cad9-eca9-4907-9466-d4b943ab5183)[![Quality Score](https://camo.githubusercontent.com/d6325534938fb80e285422d0ff0e889e8b3082e2111e3c6fc6846a287d5412f0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e5769646172742f6c61726176656c2d6e6f726d616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/nWidart/laravel-normalizer)[![Total Downloads](https://camo.githubusercontent.com/33ae3244b7deb96f8e31c2bc70021e5c7c85990754a7d5c35fe2b9d123334cba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e7769646172742f6c61726176656c2d6e6f726d616c697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nwidart/laravel-normalizer)

This package helps you normalize your data in order to save them into the database. The Goal is to having separate classes that handle the data normalization, and thus can be tested independently.

Install
-------

[](#install)

Via Composer

```
$ composer require nwidart/laravel-normalizer
```

Usage
-----

[](#usage)

### 1. Adding trait

[](#1-adding-trait)

Add the `Nwidart\LaravelNormalizer\Traits\CanNormalizeData` trait on the model(s) you wish data to be normalized.

### 2. Create Normalizer classes

[](#2-create-normalizer-classes)

Your normalizers classes need to implement the `Nwidart\LaravelNormalizer\Contracts\Normalizer` interface. This interface will add the `normalize(array $data)` method.

Example:

```
use Nwidart\LaravelNormalizer\Contracts\Normalizer;

final class CustomNormalizer implements Normalizer
{
    /**
     * Normalize the given data
     * @param array $data
     * @return array
     */
    public function normalize(array $data)
    {
        if (array_key_exists('name', $data)) {
            $data['name'] = strtoupper($data['name']);
        }

        return $data;
    }
}
```

This method needs to return the `$data` array. In here you can change the received data as you please.

### 3. Add `normalizers` class property

[](#3-add-normalizers-class-property)

On that same model, add a `protected $normalizers` property. This is where you list your normalizers, in an array.

Example:

```
use Illuminate\Database\Eloquent\Model;
use Nwidart\LaravelNormalizer\Traits\CanNormalizeData;

class Product extends Model
{
    use CanNormalizeData;
    protected $normalizers = [CustomNormalizer::class];
}
```

### 4. Normalize your data on save/update

[](#4-normalize-your-data-on-saveupdate)

Now you can start normalizing your data. This can for instance be done in your repository class.

Example:

```
public function create($data)
{
    $data = $this->model->normalize($data);

    return $this->model->create($data);
}
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Nicolas Widart](https://github.com/nwidart)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

3670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/565946b8d70f5fa172a21f87b7f0e3abdce0611cc1cd300ec8e7b360bdb0a4bc?d=identicon)[nWidart](/maintainers/nWidart)

---

Top Contributors

[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (24 commits)")

---

Tags

laravelnwidartlaravel-normalizer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nwidart-laravel-normalizer/health.svg)

```
[![Health](https://phpackages.com/badges/nwidart-laravel-normalizer/health.svg)](https://phpackages.com/packages/nwidart-laravel-normalizer)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k45.4M698](/packages/spatie-laravel-medialibrary)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M109](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k35.7M51](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.3M27](/packages/yajra-laravel-oci8)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.6M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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