Exemplo n.º 1
0
 /**
  * @return EventDTO
  */
 public function getEvent()
 {
     $this->binLogStream->binLogEvent();
     return $this->currentEvent;
 }
<?php

namespace example;

error_reporting(E_ALL);
date_default_timezone_set('UTC');
include __DIR__ . '/../vendor/autoload.php';
use MySQLReplication\Config\ConfigService;
use MySQLReplication\Event\DTO\EventDTO;
use MySQLReplication\Event\EventSubscribers;
use MySQLReplication\MySQLReplicationFactory;
$binLogStream = new MySQLReplicationFactory((new ConfigService())->makeConfigFromArray(['user' => 'root', 'ip' => '127.0.0.1', 'password' => 'root']));
/**
 * Class BenchmarkEventSubscribers
 * @package example
 */
class MyEventSubscribers extends EventSubscribers
{
    /**
     * @param EventDTO $event (your own handler more in EventSubscribers class )
     */
    public function allEvents(EventDTO $event)
    {
        // all events got __toString() implementation
        echo $event;
        // all events got JsonSerializable implementation
        echo json_encode($event, JSON_PRETTY_PRINT);
        echo 'Memory usage ' . round(memory_get_usage() / 1048576, 2) . ' MB' . PHP_EOL;
    }
}
// register your events handler here