williarin/wordpress-anonymizer

无需WordPress安装即可匿名化WordPress数据库

1.0.1 2022-02-05 04:38 UTC

This package is auto-updated.

Last update: 2024-09-05 11:37:35 UTC


README

介绍

此存储库可以作为第三方库或作为独立Docker应用程序使用。

主要用例是在将数据库提交到VCS存储库之前匿名化包含用户和客户数据的数据库。它将匿名化WordPress基础数据和WooCommerce数据。

Docker独立使用

运行以下命令以自动匿名化您的WordPress数据库。

警告!此操作不可逆。在进行操作之前请备份数据库。要自动备份WordPress数据库,您可以使用 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

变量

将库安装到您的项目中

要集成此库到您的项目,请使用Composer安装

composer require williarin/wordpress-anonymizer

用法

$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();

许可证

MIT

版权(c)2022,William Arin