PHPackages                             ramiroestrella/laravel-database-anonymize - 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. [Security](/categories/security)
4. /
5. ramiroestrella/laravel-database-anonymize

ActiveLibrary[Security](/categories/security)

ramiroestrella/laravel-database-anonymize
=========================================

Laravel Database Anonymize is a package designed to streamline data anonymization, enabling organizations to safeguard privacy, comply with regulations, reduce the risk of data breaches, and share data securely.

1.0.8(3mo ago)11.5k↓50%MITPHPPHP ^8.1

Since Jan 10Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/balance3840/laravel-database-anonymize)[ Packagist](https://packagist.org/packages/ramiroestrella/laravel-database-anonymize)[ RSS](/packages/ramiroestrella-laravel-database-anonymize/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Database Anonymize
==========================

[](#laravel-database-anonymize)

**Laravel Database Anonymize** is a package designed to streamline data anonymization, enabling organizations to safeguard privacy, comply with regulations, reduce the risk of data breaches, and share data securely.

### Key Benefits:

[](#key-benefits)

1. **Privacy Protection**
    Anonymization removes or masks sensitive personally identifiable information (PII) such as names, addresses, emails, and phone numbers, preserving individuals' privacy.
2. **Regulatory Compliance**
    Meet legal and industry standards like the EU's General Data Protection Regulation (GDPR) by anonymizing sensitive data to ensure compliance.
3. **Risk Mitigation**
    Minimize the impact of data breaches by reducing the exposure of sensitive information, thereby safeguarding against financial losses, reputational damage, and identity theft.
4. **Secure Data Sharing**
    Share anonymized datasets with researchers or other organizations without compromising privacy, fostering collaboration and innovation in fields like healthcare, finance, and social sciences.

---

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

[](#installation)

Install the package via Composer:

```
composer require ramiroestrella/laravel-database-anonymize
```

Publish the configuration file with:

```
php artisan vendor:publish --provider="RamiroEstrella\LaravelDatabaseAnonymize\Providers\DatabaseAnonymizeServiceProvider"
```

The published configuration file (`config/laravel-database-anonymize.php`) includes:

```
return [
    'locale' => 'en_US',
    'chunk_size' => 1000,

    /*
    |--------------------------------------------------------------------------
    | Restricted Environments
    |--------------------------------------------------------------------------
    | Define environments (e.g., production, staging) that require confirmation
    | before running anonymization commands for added security.
    */
    'restricted_env' => ['production', 'staging'],

    /*
    |--------------------------------------------------------------------------
    | Model Ordering
    |--------------------------------------------------------------------------
    | Optionally define the order of model anonymization. Priority models are
    | processed first to ensure dependencies are handled correctly.
    */
    'priority_models' => [],
];
```

---

Usage
-----

[](#usage)

### Step 1: Implement the `Anonymizable` Trait

[](#step-1-implement-the-anonymizable-trait)

Add the `Anonymizable` trait to models containing sensitive data and define the `anonymizableAttributes` method.

Example (`App\Models\User`):

```
