承接 milenmk/laravel-gdpr-exporter 相关项目开发

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

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

milenmk/laravel-gdpr-exporter

Composer 安装命令:

composer require milenmk/laravel-gdpr-exporter

包简介

A GDPR-compliant user data exporter with Livewire support.

README 文档

README

Latest Version on Packagist Total Downloads GitHub User's stars Laravel 10 Support PHP Version Support License Contributions Welcome Sponsor me

A lightweight Livewire component for exporting user data in multiple GDPR-compliant formats: JSON, CSV, XML, and HTML.

✨ Features

  • Export authenticated user data in:
    • ✅ JSON
    • ✅ CSV
    • ✅ XML
    • ✅ HTML
  • Automatically loads all Eloquent relations
  • Filter out ID columns and other columns ending in _id or _by
  • Streamed downloads
  • Beautifully formatted output
  • Built with Livewire 3
  • Configurable relation detection (reflection or whitelist)
  • Customizable export settings

🧰 Requirements

  • PHP 8.2+
  • Laravel 10+
  • Livewire 3+

📦 Installation

composer require milenmk/laravel-gdpr-exporter

🚀 Usage

  1. Add the Livewire component in your Blade view:

    <livewire:gdpr-exporter />
    
  2. Optional: Publish the configuration file:

    php artisan vendor:publish --tag=laravel-gdpr-exporter-config
    
  3. Optional: Publish the Blade view if you want to customize the UI:

    php artisan vendor:publish --tag=laravel-gdpr-exporter-views
    

    This will publish the file in resources/views/vendor/laravel-gdpr-exporter/livewire/gdpr.blade.php

📁 Export Formats

Format Output Content-Type
JSON Pretty-printed user data application/json
CSV Key-value flat list text/csv
XML Nested XML document application/xml
HTML Styled HTML table text/html

⚙️ Configuration

The package provides several configuration options in config/gdpr-exporter.php:

User Model

Specify the user model class to use for GDPR exports:

'user_model' => env('GDPR_USER_MODEL', 'App\Models\User'),

Relations Detection

Choose between automatic reflection-based detection or explicit whitelist:

'relations_detection' => [
    'method' => env('GDPR_RELATIONS_METHOD', 'whitelist'), // 'reflection' or 'whitelist'
    
    // When using 'whitelist' method, only these relations will be loaded
    'whitelist' => [
        // Example: 'posts', 'profile', 'roles', 'permissions'
    ],
    
    // When using 'reflection' method, these methods will be excluded
    'excluded_methods' => [
        'delete', 'destroy', 'forceDelete', 'restore', 'save',
        // ... more methods listed in the config file
    ],
],

Export Settings

Configure how data is processed during export:

'export' => [
    // Whether to remove ID fields from the exported data
    'remove_ids' => env('GDPR_REMOVE_IDS', true),
    
    // Whether to flatten pivot table data in the export
    'flatten_pivot' => env('GDPR_FLATTEN_PIVOT', true),
],

🧠 How It Works

  • Uses reflection to detect all Eloquent relationships on the User model.
  • Loads relations and transforms the entire user structure to an array.
  • Removes internal ID fields and flattens pivot data.
  • Outputs the cleaned data in the selected format.

🔧 Troubleshooting

"Table 'notifications' doesn't exist" Error

If you encounter an error like SQLSTATE[42S02]: Base table or view not found: 1146 Table 'notifications' doesn't exist, this happens when your User model uses the Notifiable trait but you don't have the notifications database table (common when using only email notifications).

Solutions:

  1. Use Whitelist Method (Recommended): Configure the package to use the whitelist method and only include the relations you want to export:

    // config/gdpr-exporter.php
    'relations_detection' => [
        'method' => 'whitelist',
        'whitelist' => [
            'posts', 'profile', 'roles', // Add your actual relations here
            // Don't include 'notifications' if you don't have the table
        ],
    ],
  2. Exclude Notifications from Reflection: If you prefer using reflection, add 'notifications' to the excluded methods:

    // config/gdpr-exporter.php
    'relations_detection' => [
        'method' => 'reflection',
        'excluded_methods' => [
            // ... other excluded methods
            'notifications', // Add this line
        ],
    ],
  3. Create the Notifications Table: If you want to support database notifications in the future:

    php artisan notifications:table
    php artisan migrate

The package now includes built-in error handling that will gracefully skip relations that cause database errors, but using the whitelist method is still the safest approach.

Contributing

You can review the source code, report bugs, or contribute to the project by visiting the GitHub repository:

GitHub Repository

Feel free to open issues or submit pull requests. Contributions are welcome!

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

Support My Work

If this package saves you time, you can support ongoing development:
👉 Become a Patron

Other Packages

Check out my other Laravel packages:

License

This package is licensed under the MIT License. See the LICENSE file for more details.

Disclaimer

This package is provided "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, or noninfringement.

The author(s) make no guarantees regarding the accuracy, reliability, or completeness of the code, and shall not be held liable for any damages or losses arising from its use.

Please ensure you thoroughly test this package in your environment before deploying it to production.

milenmk/laravel-gdpr-exporter 适用场景与选型建议

milenmk/laravel-gdpr-exporter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.11k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 milenmk/laravel-gdpr-exporter 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-31