承接 will2therich/laravel-model-anonymizer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

will2therich/laravel-model-anonymizer

Composer 安装命令:

composer require will2therich/laravel-model-anonymizer

包简介

Declare Model Anonymize Classes To Help Anonymize Data.

README 文档

README

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

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

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

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

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

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 96
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固