Download the PHP package orange-rt/anonymize-bundle without Composer
On this page you can find all versions of the php package orange-rt/anonymize-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download orange-rt/anonymize-bundle
More information about orange-rt/anonymize-bundle
Files in orange-rt/anonymize-bundle
Package anonymize-bundle
Short Description A bundle to anonymize sensitive database data
License MIT
Informations about the package anonymize-bundle
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
Usage
Doctrine managed entities can be anonymized by annotating the properties
that you want to be anonymized. There are two annotations available,
@Anonymize
and @AnonymizeEntity
.
Anonymizing a property
Properties can be anonymized with the @Anonymize
annotation like as follows:
Upon calling php bin/console anonymize:anonymize
the property username
will be updated to $faker->email
. The faker is generated in the driver.
Anonymizing callback
Sometimes it is required that properties need an advanced or a custom way
of anonymizing said entity. If a method is annotated with the @Anonymize
annotation, the method is called. If you need a faker you can typehint the
parameter, like in the example below:
Upon anonymizing the person, a UniqueGenerator is created for the method and the method is invoked with the generator. The username will be the same as the email, and it will be a uniquely generated email.
Excluding entities
It is possible to either skip a property, or to skip an entire object.
Skipping objects
It is either possible to blacklist an object, or to whitelist an object. The exclusions are done with a key value pair, where the key is the name of the property, and the value is either a direct match with the value, or a regex.
The inclusions are done in the same way, if one of the inclusions is matched, the object is anonymized.
In the example below, every person will be anonymized except for the people
that have a username that ends with @orangert.nl
.
Changing the faker locale
The default faker locale is nl_NL
. To set the locale:
Unique variables
For properties like email and usernames, unique values should be used.
The Anonymize property has a unique=true
flag to set use the
UniqueGenerator
provided by the Faker library. If a callback needs
the UniqueGenerator, typehint the generator with the UniqueGenerator.
Contributing
Pull requests
There might be open issues in the Github issue tracker. I'm open to receive new pull requests and will check them as soon as I possibly can.
Issues
If you find any bugs, please report them at the issue tracker. I will look at them as soon as I possibly can.
All versions of anonymize-bundle with dependencies
symfony/console Version ~2.7|~3.0|~4.0
symfony/dependency-injection Version ~2.7|~3.0|~4.0
nyholm/symfony-bundle-test Version ^1.2
phpunit/phpunit Version ^6.4
doctrine/annotations Version ^1.5
jms/metadata Version ^1.6
fzaninotto/faker Version ^1.7
doctrine/orm Version ^2.5
roave/security-advisories Version dev-master