PHP code example of moln / php-mysql-replication

1. Go to this page and download the library: Download moln/php-mysql-replication library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moln / php-mysql-replication example snippets


  (new ConfigBuilder())->withTablesOnly(['log_\d+'])->build(); // Table `log_20240101`
  

  (new ConfigBuilder())
    ->withRetry(-1) // Retry always.
    ->withRetry(0)  // Disable retry feature. (Default)
    ->withRetry(2)  // Retry twice.
  

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user'@'host';

GRANT SELECT ON `dbName`.* TO 'user'@'host';
sh
php example/dump_events.php
sh
php example/benchmark.php