williarin / wordpress-anonymizer
Anonymize a WordPress database without a WordPress installation
Installs: 504
Dependents: 0
Suggesters: 0
Security: 0
Stars: 18
Watchers: 2
Forks: 1
Open Issues: 6
Type:project
Requires
- php: >=8.0
- doctrine/dbal: ^3.3
- fakerphp/faker: ^1.18
- symfony/config: ^6.0
- symfony/console: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/dotenv: ^6.0
- symfony/string: ^6.0
- symfony/yaml: ^6.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.23
- kubawerlos/php-cs-fixer-custom-fixers: ^3.7
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^6.0
- symplify/coding-standard: ^10.0
- symplify/easy-coding-standard: ^10.0
This package is auto-updated.
Last update: 2024-11-05 12:04:45 UTC
README
Introduction
This repository can be used as a third party library or as a standalone Docker application.
The main use case is to anonymize a database filled with user and customer data before committing it to a VCS repository. It will anonymize both WordPress base data and WooCommerce data.
Docker standalone usage
Run this command to automatically anonymize your WordPress database.
WARNING! This operation is irreversible. Make a database backup before proceeding. To make automatic backups of your WordPress database, you can use williarin/secure-mysql-backups.
docker run --rm \
-e DATABASE_URL='mysql://user:user@127.0.0.1:3306/wp_mywebsite?serverVersion=8.0&charset=utf8mb4' \
williarin/wordpress-anonymizer
Variables:
Installation as a library in your project
To integrate this library to your project, install it with Composer:
composer require williarin/wordpress-anonymizer
Usage
$faker = Faker\Factory::create(); $connection = DriverManager::getConnection(['url' => 'mysql://user:pass@localhost:3306/wp_mywebsite?serverVersion=8.0']); $tablePrefix = 'wp_'; $anonymizer = new Anonymizer([ new UserProvider($connection, $faker, $tablePrefix), new UserMetaProvider($connection, $faker, $tablePrefix), new CommentProvider($connection, $faker, $tablePrefix), new WoocommerceUserMetaProvider($connection, $faker, $tablePrefix), new WoocommercePostMetaProvider($connection, $faker, $tablePrefix), ]); // Anonymize the whole database at once $anonymizer->anonymize(); // or use a provider to anonymize only a part $commentProvider = new CommentProvider($connection, $faker, $tablePrefix); $commentProvider->anonymize();
License
Copyright (c) 2022, William Arin