php-shark-tank / anonymizer-bundle
Symfony bundle to integrate anonymizer component into a symfony application
Package info
github.com/PHPSharkTank/AnonymizerBundle
Type:symfony-bundle
pkg:composer/php-shark-tank/anonymizer-bundle
Requires
- php: >=8.2 <8.6
- php-shark-tank/anonymizer: ^1.1.1
- symfony/config: ^6.4 || ^7.4 || ^8.1
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.1
- symfony/http-kernel: ^6.4 || ^7.4 || ^8.1
- symfony/yaml: ^6.4 || ^7.4 || ^8.1
Requires (Dev)
- fakerphp/faker: ^1.24
- friendsofphp/php-cs-fixer: ^3.95
- kubawerlos/php-cs-fixer-custom-fixers: ^3.37
- nyholm/symfony-bundle-test: ^3.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.3
- phpstan/phpstan-symfony: ^2.1
- phpunit/phpunit: ^11.5 || ^12.5 || ^13.4
- symfony/expression-language: ^6.4 || ^7.4 || ^8.1
- symfony/framework-bundle: ^6.4 || ^7.4 || ^8.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-30 10:40:54 UTC
README
Symfony bundle to integrate the Anonymizer library into a Symfony application.
Installation
composer require php-shark-tank/anonymizer-bundle
Register the bundle in config/bundles.php (Symfony Flex does this automatically):
return [ // ... PHPSharkTank\AnonymizerBundle\AnonymizerBundle::class => ['all' => true], ];
Usage
Inject PHPSharkTank\Anonymizer\AnonymizerInterface (or the anonymizer service) and pass the objects to anonymize:
use PHPSharkTank\Anonymizer\AnonymizerInterface; final class AnonymizeUserHandler { public function __construct( private readonly AnonymizerInterface $anonymizer, ) {} public function __invoke(User $user): void { $this->anonymizer->process($user); } }
How to mark classes and properties for anonymization is described in the library documentation.
Services implementing PHPSharkTank\Anonymizer\Handler\HandlerInterface or PHPSharkTank\Anonymizer\Registry\HandlerRegistryInterface are registered automatically when autoconfiguration is enabled.
Configuration
# config/packages/sharktank_anonymizer.yaml sharktank_anonymizer: # register the public "anonymizer" service alias enable_alias: true exclusion_strategy: # skip objects/properties via #[Skip] expressions, requires symfony/expression-language expression: enabled: false # cache the mapping metadata in the cache.<pool> service cache: enabled: false pool: system # enable the faker handlers, requires fakerphp/faker faker: enabled: false # service id of a Faker\Generator id: faker # YAML mapping files, in addition to the PHP attributes yaml_config: []