intermax/blur 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

intermax/blur

Composer 安装命令:

composer require intermax/blur

包简介

Package for Laravel to help obfuscate your database.

README 文档

README

Latest Version on Packagist Total Downloads License

Blur is a Laravel package that helps you obfuscate sensitive data in your database. It's perfect for creating anonymized copies of production databases for development and testing environments.

Features

  • 🔄 Obfuscate specific tables and columns in your database
  • 🧩 Use Faker to generate realistic but fake data
  • 🚀 Memory-optimized for handling large datasets
  • 🔍 Interactive mode to select which tables to obfuscate
  • 🛠️ Customizable obfuscation strategies
  • 🔒 Safety checks to prevent running in production environments

Installation

You can install the package via composer:

composer require intermax/blur

After installation, publish the configuration file:

php artisan vendor:publish --provider="Intermax\Blur\BlurServiceProvider"

Configuration

After publishing the configuration, you can find the configuration file at config/blur.php. Here's an example configuration:

<?php

declare(strict_types=1);

return [
    'tables' => [
        'users' => [
            'columns' => [
                'name' => 'faker:name',
                'email' => 'faker:email',
                // Add more columns as needed
            ],
            // 'chunk_size' => 2000, // Optional: Set a chunk size; higher is faster but will use more memory
            // 'keys' => ['id'], // Optional: Specify when the automatic discovery won't work
            // 'method' => 'update', // Optional: Use 'clear' to truncate the table instead
        ],
        // Add more tables as needed
    ],
];

Configuration Options

  • tables: An array of tables to obfuscate
    • columns: (Optional, can be omitted when the table needs to be cleared) The columns to obfuscate and the obfuscation method to use. Only columns that should be obfuscated need to be specified.
    • chunk_size: (Optional) The number of records to process at once (default: 2000). See Performance Considerations
    • keys: (Optional) The key columns to use. The key columns are discovered when obfuscating, but if that fails (for example when there are no primary keys) the unique 'key' can be specified.
    • method: (Optional) The method to use for obfuscation (default: 'update', alternative: 'clear' to clear the table. This can be useful for tables like jobs or tables that store audit logs.)

Usage

To obfuscate your database, run the following command:

php artisan blur:obfuscate

⚠️ This will change records (as you configured) for the default database connection.

Interactive Mode

You can use the interactive mode to select which tables to obfuscate:

php artisan blur:obfuscate --interactive
# or
php artisan blur:obfuscate -i

This will display a list of configured tables and allow you to select which ones to obfuscate.

Obfuscation Methods

Faker

Blur comes with built-in support for Faker. You can use any Faker method by prefixing it with faker::

'columns' => [
    'name' => 'faker:name',
    'email' => 'faker:email',
    'phone' => 'faker:phoneNumber',
    'address' => 'faker:address',
    // See Faker documentation for more available methods
],

Custom Obfuscators

You can create your own obfuscators by implementing the Intermax\Blur\Contracts\Obfuscator interface:

<?php

namespace App\Obfuscators;

use Intermax\Blur\Contracts\Obfuscator;

class FixedStringObfuscator implements Obfuscator
{
    public function generate(?array $parameters = null): mixed
    {
        return $parameters[0] ?? 'default-value';
    }
}

Then use it in your configuration:

'columns' => [
    'some_field' => App\Obfuscators\FixedStringObfuscator::class.':custom-value',
],

Performance Considerations

Blur processes records in chunks. You can adjust the chunk_size in the configuration to balance between memory usage and performance.

License

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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

intermax/blur 适用场景与选型建议

intermax/blur 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.63k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 intermax/blur 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 intermax/blur 我们能提供哪些服务?
定制开发 / 二次开发

基于 intermax/blur 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-27