Skip to content

joonas123/laravel-anonymize-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anonymize DB with power of Faker

Installation

composer require --dev joonas1234/laravel-anonymize-db

Publish the config:

php artisan vendor:publish --tag=config --provider=Joonas1234\\LaravelAnonymizeDB\\AnonymizeDBServiceProvider

This will create config\anonymize-db.php file for you. You can use this file to configure which columns should be anonymized

Config consists of tables and fakerProviders arrays. tables is used to define which tables and columns should be anonymized. For example if you want to anonymize register numbers and owner names in cars -table, you can do it like this:

<?php

return [
    'tables' => [
        'cars' => [
            'register_number' => 'vehicleRegistration',
            'owner_name' => 'name',
        ],
    ],
    'fakerProviders' => [
        'Fakecar'
    ]
]

It is required to add FakeCar to fakerProviders so faker can utilize vehicleRegistration from Fakecar.

Modifiers

You can also use Faker's special providers: unique(), optional() and valid():

<?php

return [
    'tables' => [
        'users' => [
            'email' => 'email|unique',
        ],
    ],
]

Command to anonymize

php artisan db:anonymize

About

Anonymize specified columns in your database with the power of faker

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages