Search by

php-shark-tank / anonymizer-bundle

BachiRocKordier

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

Statistics

Installs: 15

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 1

2.0.1 2026-10-30 10:39 UTC

This package is auto-updated.

Last update: 2026-10-30 10:40:54 UTC


README

CI Coverage PHPStan semantic-release

Latest Stable Version Total Downloads PHP Version Symfony Version License

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: []