Download the PHP package n3xt0r/mysql-data-anonymizer without Composer
On this page you can find all versions of the php package n3xt0r/mysql-data-anonymizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download n3xt0r/mysql-data-anonymizer
More information about n3xt0r/mysql-data-anonymizer
Files in n3xt0r/mysql-data-anonymizer
Package mysql-data-anonymizer
Short Description Anonymize sensitive datas in test database
License
Informations about the package mysql-data-anonymizer
MySQL Data Anonymizer
MySQL Data Anonymizer is a PHP library that anonymize your data in the database. Always use the production database to test your programs, but worry about leaking cutomer data? MySQL Data Anonymizer is the right tool for you. This tool helps you replace all sensitive data with fake data. Fake data is provided by a fzaninotto/Faker generator by default, but you can also use your own generator. To improve the performance, AMP/MySQL is used to create multiple MySQL connections concurrently.
MySQL Data Anonymizer requires PHP >= 7.2.
Table of Contents
- Configuration
- Example code
- Helpers and providers
Configuration
Rename the config-sample.php file to config.php and modify the configurations to suit your environment.
NB_MAX_MYSQL_CLIENT is the max number of MySQL connections simultaneously when executing your scripts. By default, MySQL supports at most 151 connections simultaneously, but you can modify your MySQL variable 'max_connections' to break this restriction.
NB_MAX_PROMISE_IN_LOOP is the max number of promises we keep in the promise table. Each promise represents the future result of an SQL query. The larger the number, the faster the execution will be. But you have to be careful that holding a large number of promises will consume too much memory and CPU resources. If your processor can't afford it, the run time will be at least 10 times longer than expected. If you don't know too much about the performance of your processor, just leave this variable to 50, or even 20 if you are not quite confident on it.
DEFAULT_GENERATOR_LOCALE influences the generated data's language and format by Faker's generator. You can find the full list of locales from here
Example code
For more fake data types and details about fake data generator, you can find what you want from fzaninotto/Faker's Github page
Helpers and providers
You can add your own helper and generator classes in src/helpers and src/providers. File names of helpers and providers need to keep these format : 'XXXHelper.php', 'XXXProvider.php', or they won't be loaded.
An example of customize helper:
Then in your script, you can use it like this:
An example of customize provider:
Then in your script, you can use it like this:
forked from globalis-ms