1- <?php
2-
3- namespace example ;
4-
5- error_reporting (E_ALL );
6- ini_set ('display_errors ' , 1 );
7- date_default_timezone_set ('UTC ' );
8- include __DIR__ . '/../vendor/autoload.php ' ;
9-
10- use MySQLReplication \Config \ConfigService ;
11- use MySQLReplication \Event \DTO \EventDTO ;
12- use MySQLReplication \Event \EventSubscribers ;
13- use MySQLReplication \MySQLReplicationFactory ;
14-
15- $ binLogStream = new MySQLReplicationFactory (
16- (new ConfigService ())->makeConfigFromArray ([
17- 'user ' => 'root ' ,
18- 'ip ' => '127.0.0.1 ' ,
19- 'password ' => 'root ' ,
20- //'mariaDbGtid' => '1-1-3,0-1-88',
21- //'gtid' => '9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592',
22- ])
23- );
24-
25- /**
26- * Class BenchmarkEventSubscribers
27- * @package example
28- */
29- class MyEventSubscribers extends EventSubscribers
30- {
31- /**
32- * @param EventDTO $event (your own handler more in EventSubscribers class )
33- */
34- public function allEvents (EventDTO $ event )
35- {
36- // all events got __toString() implementation
37- echo $ event ;
38-
39- // all events got JsonSerializable implementation
40- //echo json_encode($result, JSON_PRETTY_PRINT);
41-
42- echo 'Memory usage ' . round (memory_get_usage () / 1048576 , 2 ) . ' MB ' . PHP_EOL ;
43- }
44- }
45-
46- // register your events handler here
47- $ binLogStream ->registerSubscriber (new MyEventSubscribers ());
48-
49- // start consuming events
50- while (1 ) {
51- $ binLogStream ->binLogEvent ();
1+ <?php
2+
3+ namespace example ;
4+
5+ error_reporting (E_ALL );
6+ ini_set ('display_errors ' , 1 );
7+ date_default_timezone_set ('UTC ' );
8+ include __DIR__ . '/../vendor/autoload.php ' ;
9+
10+ use MySQLReplication \Config \ConfigService ;
11+ use MySQLReplication \Event \DTO \EventDTO ;
12+ use MySQLReplication \Event \EventSubscribers ;
13+ use MySQLReplication \MySQLReplicationFactory ;
14+
15+ $ binLogStream = new MySQLReplicationFactory (
16+ (new ConfigService ())->makeConfigFromArray ([
17+ 'user ' => 'root ' ,
18+ 'ip ' => '127.0.0.1 ' ,
19+ 'password ' => 'root ' ,
20+ //'mariaDbGtid' => '1-1-3,0-1-88',
21+ //'gtid' => '9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592',
22+ ])
23+ );
24+
25+ /**
26+ * Class BenchmarkEventSubscribers
27+ * @package example
28+ */
29+ class MyEventSubscribers extends EventSubscribers
30+ {
31+ /**
32+ * @param EventDTO $event (your own handler more in EventSubscribers class )
33+ */
34+ public function allEvents (EventDTO $ event )
35+ {
36+ // all events got __toString() implementation
37+ echo $ event ;
38+
39+ // all events got JsonSerializable implementation
40+ //echo json_encode($result, JSON_PRETTY_PRINT);
41+
42+ echo 'Memory usage ' . round (memory_get_usage () / 1048576 , 2 ) . ' MB ' . PHP_EOL ;
43+ }
44+ }
45+
46+ // register your events handler here
47+ $ binLogStream ->registerSubscriber (new MyEventSubscribers ());
48+
49+ // start consuming events
50+ while (1 ) {
51+ $ binLogStream ->binLogEvent ();
5252}
0 commit comments