PHPackages                             will2therich/laravel-model-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. will2therich/laravel-model-anonymizer

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

will2therich/laravel-model-anonymizer
=====================================

Declare Model Anonymize Classes To Help Anonymize Data.

1.0.0(2y ago)270MITPHP

Since Apr 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/will2therich/laravel-model-anonymizer)[ Packagist](https://packagist.org/packages/will2therich/laravel-model-anonymizer)[ RSS](/packages/will2therich-laravel-model-anonymizer/feed)WikiDiscussions master Synced 1mo ago

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

[![LaravelModelAnonymizer](https://private-user-images.githubusercontent.com/24435180/323575069-36bd8957-85ca-4df4-96e1-fdf147ed1171.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM4MjU2OTEsIm5iZiI6MTc3MzgyNTM5MSwicGF0aCI6Ii8yNDQzNTE4MC8zMjM1NzUwNjktMzZiZDg5NTctODVjYS00ZGY0LTk2ZTEtZmRmMTQ3ZWQxMTcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzE4VDA5MTYzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE4Yzc0ZTExZTJlYmM0NjFlZDk1NGIwMDk1OTA1M2RkYTE1N2IyMmU4ODVjYzRhOGI1MjA2ZjVkMDE2ZGQ4N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Xup_GoGnGd3iLKou2obcAJ1hvqDPaFeDRSQP1AQjvuE)](https://private-user-images.githubusercontent.com/24435180/323575069-36bd8957-85ca-4df4-96e1-fdf147ed1171.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM4MjU2OTEsIm5iZiI6MTc3MzgyNTM5MSwicGF0aCI6Ii8yNDQzNTE4MC8zMjM1NzUwNjktMzZiZDg5NTctODVjYS00ZGY0LTk2ZTEtZmRmMTQ3ZWQxMTcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzE4VDA5MTYzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE4Yzc0ZTExZTJlYmM0NjFlZDk1NGIwMDk1OTA1M2RkYTE1N2IyMmU4ODVjYzRhOGI1MjA2ZjVkMDE2ZGQ4N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Xup_GoGnGd3iLKou2obcAJ1hvqDPaFeDRSQP1AQjvuE)

LaravelModelAnonymizer
======================

[](#laravelmodelanonymizer)

LaravelModelAnonymizer is a Laravel package designed to help developers anonymize existing data in their models. This is particularly useful for creating non-production datasets where sensitive information needs to be obscured without affecting the integrity of the application data.

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

[](#installation)

To install the package, run the following command in your Laravel project:

`composer require will2therich/laravel-model-anonymizer`

After the package is installed, you need to set up the environment by running:

`php artisan model-anonymizer:install`

This command creates a directory called `Anonymize` under your main `app` folder. Here, you can define your anonymization classes.

Creating Anonymization Classes
------------------------------

[](#creating-anonymization-classes)

Anonymization classes should be placed in the `app/Anonymize` directory. Each class must implement the `AnonymizeInterface` and define how each model attribute should be anonymized. Here is a stub to get you started:

```
namespace App\Anonymize;

use Faker\Factory;
use Illuminate\Database\Eloquent\Model;
use will2therich\LaravelModelAnonymizer\Contracts\AnonymizeInterface;

class User implements AnonymizeInterface
{
    public static $model = \App\Models\User::class;

    public static $name = "User";

    public static function anonymize(Model $model)
    {
        $faker = Factory::create();

        $model->email = $faker->unique()->email();
        $model->save();
    }

}
```

- Replace the content of the `anonymize` method with the appropriate Faker methods to suit your specific model's needs.
- Replace `$model` With the desired model
- Replace `$name` With a name for the command to use

Usage
-----

[](#usage)

Once you have set up your anonymization classes, you can anonymize your database by running:

`php artisan db:model-anonymize`

This command will iterate through each model anonymizer defined in your `Anonymize` directory and anonymize every database item accordingly.

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

[](#contributing)

Contributions to LaravelModelAnonymizer are welcome! Please ensure that your code adheres to the Laravel coding standards and include tests for new features or fixes.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

754d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/10797b4583c2ea8930c9224c9262c21f26789005a197243eeaf58a56ad8c0424?d=identicon)[will2therich](/maintainers/will2therich)

---

Top Contributors

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

---

Tags

phplaraveleloquentmodelsanonymization

### Embed Badge

![Health badge](/badges/will2therich-laravel-model-anonymizer/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[langleyfoxall/xero-laravel

💸 Access the Xero accounting system using an Eloquent-like syntax

86235.1k](/packages/langleyfoxall-xero-laravel)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3516.7k3](/packages/wayofdev-laravel-cycle-orm-adapter)[salehhashemi/laravel-repository

Implementing the repository pattern for Laravel projects.

2010.5k](/packages/salehhashemi-laravel-repository)

PHPackages © 2026

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