Skip to content

alializade/laravel-masked-db-dump

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Masked DB Dump

This package is a fork of masked-db-dump, A database dumping package that allows you to replace and mask columns while dumping your database.

Installation

You can install the package via composer:

composer require alializade/laravel-masked-db-dump

Usage

Use this dump schema definition to remove, replace or mask certain parts of your database tables.

use AliAlizade\LaravelMaskedDumper\DumpSchema;
use AliAlizade\LaravelMaskedDumper\TableDefinitions\TableDefinition;
use Faker\Generator as Faker;

class CoreServiceProvider extends ServiceProvider
{
    // ...
    public function boot(): void
    {
        //... 
        
        $this->app->singleton('masked_dump_default', function () {
            return DumpSchema::define('mysql')
                ->allTables()
                ->table('users', function (TableDefinition $table) {
                    $table->replace('name', function (Faker $faker) {
                        return $faker->name;
                    });
                    $table->replace('email', function (Faker $faker) {
                        return $faker->lastName().'@fake.com';
                    });
                    $table->replace('password', function (Faker $faker) {
                        return $password = bcrypt('secret');
                    });
                })
                ->schemaOnly('personal_access_tokens')
        });
        // ...
}
$ php artisan db:masked-dump output.sql

$ php artisan db:masked-dump output.sql --gzip

Documentation

The documentation can be found on the website.

Security

If you discover any security related issues, please email ali.alizade@outlook.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

About

Dump masked information from your database

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%