nowo-tech/anonymize-bundle

Symfony bundle for anonymizing database records using Doctrine attributes and Faker generators. Perfect for test data generation, GDPR compliance, and data masking in development environments.

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Type:symfony-bundle

pkg:composer/nowo-tech/anonymize-bundle

v0.0.22 2026-01-21 09:28 UTC

README

CI Latest Stable Version License PHP Version Require GitHub stars

⭐ Found this project useful? Give it a star on GitHub! It helps us maintain and improve the project.

Symfony bundle for database anonymization, test data generation, and GDPR compliance. Anonymize database records using Doctrine attributes and Faker generators. Perfect for development environments, testing, data masking, and privacy compliance.

πŸ“‹ Compatible with Symfony 6.1+, 7.x, and 8.x - This bundle requires Symfony 6.1 or higher (Symfony 6.0 is not supported).

What is this?

This bundle helps you anonymize sensitive data in your Symfony applications for:

  • πŸ§ͺ Test data generation - Create realistic anonymized test datasets
  • πŸ”’ GDPR compliance - Anonymize personal data for development/testing
  • 🎭 Data masking - Replace sensitive information with fake but realistic data
  • πŸš€ Development safety - Work with anonymized data instead of real user data
  • πŸ“Š Database anonymization - Anonymize entire databases or specific entities

⚠️ Important: This bundle is development-only and should never be installed or used in production environments. The bundle includes built-in protection to prevent execution in production.

Quick Search Terms

Looking for: database anonymization, test data generator, GDPR compliance, data masking, Symfony anonymize, Doctrine anonymization, Faker bundle, privacy tools, PII anonymization, data privacy, test fixtures, development tools? You've found the right bundle!

Features

  • βœ… Attribute-based anonymization configuration
  • βœ… Support for multiple Doctrine connections
  • βœ… Multiple faker types (32 total: email, name, surname, age, phone, IBAN, credit card, address, date, username, url, company, masking, password, ip_address, mac_address, uuid, hash, coordinate, color, boolean, numeric, file, json, text, enum, country, language, hash_preserve, shuffle, constant, custom service)
  • βœ… Weight-based anonymization order
  • βœ… Pattern-based inclusion/exclusion filters
  • βœ… Support for MySQL and PostgreSQL (MongoDB infrastructure ready in demos, ODM support coming soon)
  • βœ… Batch processing for large datasets
  • βœ… Dry-run mode for testing
  • βœ… Anonymization tracking with AnonymizableTrait and anonymized column
  • βœ… Pre-flight checks: Comprehensive validation before execution
  • βœ… Progress bars: Visual progress indicators with real-time updates
  • βœ… Enhanced environment protection: Multiple safety layers
  • βœ… Debug and verbose modes: Detailed output for debugging
  • βœ… Interactive mode: Step-by-step confirmations for safer anonymization
  • βœ… Enhanced reporting: Export statistics to JSON/CSV with success rates
  • βœ… Database export: Export databases to files with optional compression
  • βœ… Configurable output directories: Customize where statistics and exports are saved

Installation

⚠️ Important: This bundle is development-only. Always install it as a dev dependency.

composer require nowo-tech/anonymize-bundle --dev

Then, register the bundle in your config/bundles.php only for dev and test environments:

<?php

return [
    // ...
    Nowo\AnonymizeBundle\AnonymizeBundle::class => ['dev' => true, 'test' => true],
];

⚠️ Security: The bundle will automatically prevent execution in production environments. The command will fail if run outside of dev or test environments.

Quick Start

  1. Mark an entity for anonymization with the #[Anonymize] attribute:
use Nowo\AnonymizeBundle\Attribute\Anonymize;
use Nowo\AnonymizeBundle\Attribute\AnonymizeProperty;

#[ORM\Entity]
#[Anonymize]
class User
{
    #[AnonymizeProperty(type: 'email', weight: 1)]
    private ?string $email = null;

    #[AnonymizeProperty(type: 'name', weight: 2)]
    private ?string $firstName = null;
}
  1. Run the anonymization command:
php bin/console nowo:anonymize:run

For detailed usage examples, see USAGE.md.

Requirements

  • PHP >= 8.1, < 8.6
  • Symfony >= 6.1 || >= 7.0 || >= 8.0
  • Doctrine ORM >= 2.13 || >= 3.0
  • Doctrine Bundle >= 2.8 || >= 3.0 (3.0 required for Symfony 8)

Note: This bundle requires Symfony 6.1 or higher. Symfony 6.0 is not supported because the bundle uses the #[Autowire] attribute for dependency injection, which is only available from Symfony 6.1 onwards.

Configuration

The bundle works with default settings. If you're using Symfony Flex, the configuration file is automatically created at config/packages/dev/nowo_anonymize.yaml. Otherwise, you can configure it manually in config/packages/dev/nowo_anonymize.yaml:

nowo_anonymize:
    locale: 'en_US'              # Locale for Faker generator
    connections: []              # Specific connections to process (empty = all)
    dry_run: false              # Dry-run mode (default: false)
    batch_size: 100             # Batch size for processing records

See CONFIGURATION.md for detailed configuration options.

Commands

The bundle provides six console commands:

  • nowo:anonymize:run - Main anonymization command (supports MySQL, PostgreSQL, SQLite)
  • nowo:anonymize:history - View and manage anonymization history (list, view, compare runs)
  • nowo:anonymize:export-db - Export databases to files with optional compression (MySQL, PostgreSQL, SQLite, MongoDB)
  • nowo:anonymize:generate-column-migration - Generate SQL migrations for anonymized column (MySQL, PostgreSQL, SQLite)
  • nowo:anonymize:generate-mongo-field - Generate MongoDB script to add anonymized field to documents
  • nowo:anonymize:info - Display information about anonymizers

Note: MongoDB ODM support is planned for future releases. The nowo:anonymize:run command currently only processes Doctrine ORM connections. However, you can use nowo:anonymize:generate-mongo-field to prepare MongoDB documents with the anonymized field.

See COMMANDS.md for detailed command documentation and examples.

Faker Types

The bundle supports 32 faker types for anonymizing various data types, including:

  • Basic: email, name, surname, age, phone, IBAN, credit_card
  • Advanced: address, date, username, url, company, masking, password, ip_address, mac_address, uuid, hash, coordinate, color, boolean, numeric, file, json, text, enum, country, language
  • Data Preservation: hash_preserve, shuffle, constant
  • Custom: service (custom service faker)

See FAKERS.md for complete list and configuration options.

Documentation

License

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

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute to this project.

For information about our Git workflow and branching strategy, see BRANCHING.md.

Roadmap

We have an extensive roadmap for future enhancements. See ROADMAP.md for details on planned features including:

Current Status (v0.0.18)

  • Phase 1 Progress: 100% complete (all 21 fakers implemented)
  • Total Fakers Available: 32 fakers (all fakers from Phase 1 + Phase 2 data preservation fakers)
  • Test Coverage: 216 tests, 512 assertions, 45.80% line coverage
  • Pattern Matching: Enhanced with | (OR) operator support for multiple value matching and relationship patterns (e.g., 'type.name' => '%HR')
  • MongoDB Support: Command to generate scripts for adding anonymized field to MongoDB documents
  • Relationship Patterns: Support for patterns referencing related entities using dot notation with automatic SQL JOIN construction

Planned Phases

  • Phase 1 (v0.1.0): Enhanced fakers (100% complete - all fakers implemented)
  • Phase 2 (v0.2.0): Advanced anonymization strategies (Hash Preserve, Shuffle, Relationship Preservation)
  • Phase 3 (v0.3.0): MongoDB and SQLite support
  • Phase 4 (v0.4.0): Enhanced developer experience (CLI improvements, reporting, testing tools)
  • Phase 5 (v0.5.0): Enterprise features (GDPR compliance, audit logging, API integration)
  • Phase 6 (v0.6.0): Performance and scalability improvements
  • Phase 7 (v0.7.0): Security and compliance enhancements
  • Phase 8 (v0.8.0): Advanced features (ML integration, workflow automation)

Check out the full roadmap for detailed information about upcoming features, priorities, and timelines.

Author

Created by HΓ©ctor Franco Aceituno at Nowo.tech