php-anonymizer / anonymizer-bundle
Symfony integration for PHP Anonymizer
Package info
github.com/toniliesche/php-anonymizer-bundle
Type:symfony-bundle
pkg:composer/php-anonymizer/anonymizer-bundle
Requires
- php: ^8.5
- php-anonymizer/anonymizer: ^2.0
- psr/log: ^3.0.2
- symfony/config: ^8.1.5
- symfony/console: ^8.1.9
- symfony/dependency-injection: ^8.1.9
- symfony/http-kernel: ^8.1.9
- symfony/serializer: ^8.1.9
- symfony/yaml: ^8.1.9
- thecodingmachine/safe: ^3.4
Requires (Dev)
None
Suggests
- php-anonymizer/anonymizer-faker: Enable Faker replacement strategies
- php-anonymizer/anonymizer-personas: Enable fixed European persona strategies
- php-anonymizer/anonymizer-pseudonymization: Enable keyed deterministic pseudonymisation
- php-anonymizer/anonymizer-symfony-serializer: Enable object anonymization through an application-owned Symfony Serializer
Provides
None
Conflicts
None
Replaces
None
README
Project Status
Project Info
Repo Status
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.