Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

AnonymizerBundle

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

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages