PHPackages                             indeev/laravel-rapid-db-anonymizer - 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. indeev/laravel-rapid-db-anonymizer

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

indeev/laravel-rapid-db-anonymizer
==================================

Rapidly anonymize huge amount of data

v3.0(3y ago)2457MITPHPPHP ^8.0.2

Since Oct 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/inDeev/laravel-rapid-db-anonymizer)[ Packagist](https://packagist.org/packages/indeev/laravel-rapid-db-anonymizer)[ Docs](https://github.com/indeev/laravel-rapid-db-anonymizer)[ RSS](/packages/indeev-laravel-rapid-db-anonymizer/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

Laravel Rapid DB Anonymizer
===========================

[](#laravel-rapid-db-anonymizer)

[![Latest Stable Version](https://camo.githubusercontent.com/ade200d180704be6b21abdc2c0d00c4fb3588fe07b23346ea1d762885ec09104/687474703a2f2f706f7365722e707567782e6f72672f696e646565762f6c61726176656c2d72617069642d64622d616e6f6e796d697a65722f76)](https://packagist.org/packages/indeev/laravel-rapid-db-anonymizer)[![Total Downloads](https://camo.githubusercontent.com/a37d62de285fd703f7dd5ad8cd2ff0da912253a6f894647bec84c2dd0786d2cb/687474703a2f2f706f7365722e707567782e6f72672f696e646565762f6c61726176656c2d72617069642d64622d616e6f6e796d697a65722f646f776e6c6f616473)](https://packagist.org/packages/indeev/laravel-rapid-db-anonymizer)[![Latest Unstable Version](https://camo.githubusercontent.com/35fbfd09a28fd8860425db2b43f201357a083b2248d69a6c037f577fe4ca6de4/687474703a2f2f706f7365722e707567782e6f72672f696e646565762f6c61726176656c2d72617069642d64622d616e6f6e796d697a65722f762f756e737461626c65)](https://packagist.org/packages/indeev/laravel-rapid-db-anonymizer)[![License](https://camo.githubusercontent.com/77666c8a15190157da2c600321c1bed006aa6518ac41db75da21e2d7d2c53e3d/687474703a2f2f706f7365722e707567782e6f72672f696e646565762f6c61726176656c2d72617069642d64622d616e6f6e796d697a65722f6c6963656e7365)](https://packagist.org/packages/indeev/laravel-rapid-db-anonymizer)

The package rapidly anonymizes large amounts of sensitive data throughout the database.

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

[](#installation)

You can install the package through the composer:

```
composer require indeev/laravel-rapid-db-anonymizer
```

Usage
-----

[](#usage)

In any model that contains sensitive data `use Anonymizable;` trait and `const ANONYMIZABLE = [];` constant.

```
class Customer
{
    use Anonymizable;

    const ANONYMIZABLE = [
        'name' => [
            'faker' => ['provider' => 'firstName'],
        ],
    ];
    // ...
}
```

`ANONYMIZABLE` is defined as an array of `'column_name' => [what_to_do]` values.

### Prepare ANONYMIZABLE constant

[](#prepare-anonymizable-constant)

Truncate table

```
const ANONYMIZABLE = ['truncate'];
```

**Replace column value with faker's provider** (without parameters)

```
const ANONYMIZABLE = [
        'name' => [
            'faker' => ['provider' => 'firstName'],
        ],
        // next columns
    ];
```

**Replace column value with faker's provider** (with parameters)

```
const ANONYMIZABLE = [
        'secret_code' => [
            'faker' => ['provider' => 'randomNumber', 'params' => [6, true]],
        ],
        // next columns
    ];
```

**Replace with exact value**

- if value of setTo is an array type, it is converted to json string. For instance `['foo' => 'bar']` is converted to `{"foo":"bar"}`.
- if value of setTo is `null`, it is converted to NULL. Pay special attention that column is set as *nullable*.

```
const ANONYMIZABLE = [
        'favorite_politician' => [
            'setTo' => 'CONFIDENTIAL',
        ],
        'favorite_numbers' => [
            'setTo' => [7, 13],
        ],
        'favorite_meals' => [
            'setTo' => null,
        ],
        // next columns
    ];
```

**Replace also NULL values**
By default, NULL values are skipped. If you also want to anonymize them, you must add `anonymizeNull` to the column with a value `true`.

```
const ANONYMIZABLE = [
        'shipping_address' => [
            'faker' => ['provider' => 'address'],
            'anonymizeNull' => true,
        ],
        // next columns
    ];
```

### Run anonymization

[](#run-anonymization)

To run anonymization for the entire database (all models with Anonymizable trait) use

```
php artisan db:anonymize
```

To run anonymization over a specific model use command with `--model=` option

```
php artisan db:anonymize --model=\\App\\Models\\VerificationCode
```

To run anonymizing specific columns in the entire database use command with `--columns=` option. Individual column names must be separated by comma

```
php artisan db:anonymize --columns=name,surname
```

Use a combination of the previous two options to anonymize specific columns above a specific model

```
php artisan db:anonymize --model=\\App\\Models\\User --columns=name,surname
```

Testing
-------

[](#testing)

```
composer test
```

Config
------

[](#config)

You can export config file by:

```
php artisan vendor:publish --provider="Indeev\LaravelRapidDbAnonymizer\LaravelRapidDbAnonymizerServiceProvider"
```

In config, you can modify:

- Chunk size *(default: 500)* - all 500 rows are updated by one query
- Forbidden environments *(default: production, prod)*
- Custom model directory *(default: app/Models)*
- Custom model namespace *(default: \\App\\Models)*
- Faker's locale *(default: en\_US)*

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Petr Katerinak](https://github.com/indeev)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

5

Last Release

1224d ago

Major Versions

v1.0.0 → v2.0.02021-10-10

v2.1.1 → v3.02023-02-27

PHP version history (3 changes)v1.0.0PHP ^7.4|^8.0

v2.0.0PHP ^8.0

v3.0PHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/00ca7c89cfcf385400d70eeb152888096bac038ad696756facace3b3ed351b81?d=identicon)[inDeev](/maintainers/inDeev)

---

Top Contributors

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

---

Tags

laraveldatabaseanonymizeindeevlaravel-rapid-db-anonymizer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/indeev-laravel-rapid-db-anonymizer/health.svg)

```
[![Health](https://phpackages.com/badges/indeev-laravel-rapid-db-anonymizer/health.svg)](https://phpackages.com/packages/indeev-laravel-rapid-db-anonymizer)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

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

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[aimeos/laravel-nestedset

Nested Set Model for Laravel

3714.4k6](/packages/aimeos-laravel-nestedset)[vectorial1024/laravel-cache-evict

Efficiently remove expired Laravel file/database cache data

5917.4k](/packages/vectorial1024-laravel-cache-evict)

PHPackages © 2026

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