Search by

php-anonymizer / anonymizer-bundle

tliesche

Symfony integration for PHP Anonymizer

Package info

github.com/toniliesche/php-anonymizer-bundle

Type:symfony-bundle

pkg:composer/php-anonymizer/anonymizer-bundle

Statistics

Installs: 10

Dependents: 0

Suggesters: 5

Stars: 0

Open Issues: 0

2.0.2 2026-10-26 06:38 UTC

This package is auto-updated.

Last update: 2026-10-26 07:45:59 UTC


README

Project Status

Tests Code Coverage Mutation testing badge Downloads Stars

Project Info

PHP Version Latest Version License

Repo Status

Last Commit Issues

License

This project is released under the MIT license.

See the LICENSE for more information.

Install php-anonymizer/anonymizer-bundle; Composer installs the core and required Symfony component dependencies. Symfony Flex can register the bundle; manual registration uses PhpAnonymizer\AnonymizerBundle\AnonymizerBundle.

# config/packages/anonymizer.yaml
anonymizer:
  profiles:
    customer:
      mode: redact
      key_normalization: true
      rules:
        - field: email
          strategy: star_mask
      global_rules:
        - field: email_address
      metadata:
        owner: privacy-platform
        status: active
      fragments:
        - name: contact
          rules:
            - field: phone
        - name: identity
          rules:
            - use: contact
            - field: customer_id

The core anonymizer is available through the autowireable PhpAnonymizer\Anonymizer\Application\Anonymization\AnonymizerInterface. Profile key normalization is comparison-only, and global rules apply within the configured profile at every map depth without renaming dataset keys. Fragments are profile-local ordered lists expanded during container compilation. The first fragment rule wins a fragment collision; direct profile rules replace fragment rules selecting the same field. The public ProfileInspectorInterface exposes only safe profile summaries and behavior fingerprints.

Custom extension services use explicit IDs on their tags:

App\Anonymizer\HashStrategy:
  tags:
    - { name: anonymizer.replacement_strategy, id: hash }
App\Anonymizer\CsvCodec:
  tags:
    - { name: anonymizer.payload_codec, id: csv }

Profile providers use anonymizer.profile_provider; configured profiles are consumed first, followed by tagged providers in tag order. Strategy and codec IDs must be unique and must not replace built-in IDs. YAML payloads are available as yaml automatically. Faker strategies are optional:

composer require php-anonymizer/anonymizer-faker
anonymizer:
  faker: { enabled: true, locale: en_US, seed: 1234 }

Fixed European personas are also optional:

composer require php-anonymizer/anonymizer-personas
anonymizer:
  personas: { enabled: true, locale: de }

The Bundle accepts execution limits under anonymizer.limits. Audit logging is optional and disabled by default; enable it with a configured PSR-3 logger:

anonymizer:
  audit:
    enabled: true
    logger_service: monolog.logger.anonymizer

Pseudonymization is optional; install php-anonymizer/anonymizer-pseudonymization and configure its key provider as described in the usage guide. Object anonymization is also opt-in and requires php-anonymizer/anonymizer-symfony-serializer in addition to the application- owned Symfony Serializer service. Enable anonymizer.serializer.enabled and provide that service through anonymizer.serializer.service, or use the conventional serializer service.

See the package-local usage guide.