PHP Classes

PHP MySQL Replication: Client to get MySQL replication events in pure PHP

Recommend this page to a friend!
  Info   View files Example   View files View files (81)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStarStar 87%Total: 755 All time: 4,451 This week: 108Up
Version License PHP version Categories
mysql-replication 2.0.28MIT/X Consortium ...5.6Networking, PHP 5, Databases
Description 

Author

This package implements a client to get MySQL replication events in pure PHP.

It establishes a socket connection to a MySQL binary log server to so it can listen to MySQL database changes events like insert, update, delete queries with their data as well raw SQL queries.

The events can be dumped for debugging purposes or used to replicate the database on a new server.

Recommendations

extract updated data
I want a class that can sync localdatabase with online hosting

clone mysql BIG database
Clone mysql BIG databases without export/import, but copying

Innovation Award
PHP Programming Innovation award nominee
March 2016
Number 7


Prize: One subscription to the PDF edition of the PHP Architect magazine
MySQL supports replication of data, so multiple slave servers can store the same data as the master.

The replication is done using a networking protocol that can be used by slaves to retrieve data from the servers.

This package can act as a MySQL slave, so it can replicate data from a MySQL server in pure PHP.

Manuel Lemos
Picture of Kacper Rowinski
  Performance   Level  
Name: Kacper Rowinski <contact>
Classes: 14 packages by
Country: Poland Poland
Age: 39
All time rank: 92226 in Poland Poland
Week rank: 44 Up1 in Poland Poland Up
Innovation award
Innovation award
Nominee: 8x

Example

<?php
declare(strict_types=1);

error_reporting(E_ALL);
date_default_timezone_set('UTC');
include
__DIR__ . '/../vendor/autoload.php';

use
MySQLReplication\Config\ConfigBuilder;
use
MySQLReplication\Event\DTO\EventDTO;
use
MySQLReplication\Event\EventSubscribers;
use
MySQLReplication\MySQLReplicationFactory;

/**
 * Your db configuration
 * @see ConfigBuilder
 * @link https://github.com/krowinski/php-mysql-replication/blob/master/README.md
 */
$binLogStream = new MySQLReplicationFactory(
    (new
ConfigBuilder())
        ->
withUser('root')
        ->
withHost('127.0.0.1')
        ->
withPassword('root')
        ->
withPort(3306)
        ->
withSlaveId(100)
        ->
withHeartbeatPeriod(2)
        ->
build()
);

/**
 * Register your events handler
 * @see EventSubscribers
 */
$binLogStream->registerSubscriber(
    new class() extends
EventSubscribers
   
{
        public function
allEvents(EventDTO $event): void
       
{
           
// 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;
        }
    }
);

// start consuming events
$binLogStream->run();


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder image.travis (1 file)
Files folder imageexample (3 files)
Files folder imagesrc (1 directory)
Files folder imagetests (1 file, 2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file ISSUE_TEMPLATE.md Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. LICENSE
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file tests.yml Data Auxiliary data

  Files folder image Files  /  .travis  
File Role Description
  Accessible without login Plain text file initializedb.sh Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file benchmark.php Example Example script
  Accessible without login Plain text file dump_events.php Example Example script
  Plain text file resuming.php Class Class source

  Files folder image Files  /  src  
File Role Description
Files folder imageMySQLReplication (1 file, 11 directories)

  Files folder image Files  /  src  /  MySQLReplication  
File Role Description
Files folder imageBinaryDataReader (1 file)
Files folder imageBinLog (4 files)
Files folder imageCache (1 file)
Files folder imageConfig (3 files)
Files folder imageDefinitions (3 files)
Files folder imageEvent (9 files, 2 directories)
Files folder imageException (1 file)
Files folder imageGtid (3 files)
Files folder imageJsonBinaryDecoder (4 files)
Files folder imageRepository (6 files)
Files folder imageSocket (3 files)
  Plain text file MySQLReplicationFactory.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  BinaryDataReader  
File Role Description
  Plain text file BinaryDataReader.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  BinLog  
File Role Description
  Plain text file BinLogCurrent.php Class Class source
  Plain text file BinLogException.php Class Class source
  Plain text file BinLogServerInfo.php Class Class source
  Plain text file BinLogSocketConnect.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Cache  
File Role Description
  Plain text file ArrayCache.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Config  
File Role Description
  Accessible without login Plain text file Config.php Conf. Configuration script
  Accessible without login Plain text file ConfigBuilder.php Conf. Configuration script
  Plain text file ConfigException.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Definitions  
File Role Description
  Plain text file ConstEventsNames.php Class Class source
  Plain text file ConstEventType.php Class Class source
  Plain text file ConstFieldType.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Event  
File Role Description
Files folder imageDTO (13 files)
Files folder imageRowEvent (6 files)
  Plain text file Event.php Class Class source
  Plain text file EventCommon.php Class Class source
  Plain text file EventInfo.php Class Class source
  Plain text file EventSubscribers.php Class Class source
  Plain text file GtidEvent.php Class Class source
  Plain text file MariaDbGtidEvent.php Class Class source
  Plain text file QueryEvent.php Class Class source
  Plain text file RotateEvent.php Class Class source
  Plain text file XidEvent.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Event  /  DTO  
File Role Description
  Plain text file DeleteRowsDTO.php Class Class source
  Plain text file EventDTO.php Class Class source
  Plain text file FormatDescriptionEventDTO.php Class Class source
  Plain text file GTIDLogDTO.php Class Class source
  Plain text file HeartbeatDTO.php Class Class source
  Plain text file MariaDbGtidLogDTO.php Class Class source
  Plain text file QueryDTO.php Class Class source
  Accessible without login Plain text file RotateDTO.php Conf. Configuration script
  Plain text file RowsDTO.php Class Class source
  Plain text file TableMapDTO.php Class Class source
  Plain text file UpdateRowsDTO.php Class Class source
  Plain text file WriteRowsDTO.php Class Class source
  Plain text file XidDTO.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Event  /  RowEvent  
File Role Description
  Plain text file ColumnDTO.php Class Class source
  Plain text file ColumnDTOCollection.php Class Class source
  Plain text file RowEvent.php Class Class source
  Plain text file RowEventBuilder.php Class Class source
  Plain text file RowEventFactory.php Class Class source
  Plain text file TableMap.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Exception  
File Role Description
  Plain text file MySQLReplicationException.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Gtid  
File Role Description
  Accessible without login Plain text file Gtid.php Conf. Configuration script
  Plain text file GtidCollection.php Class Class source
  Plain text file GtidException.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  JsonBinaryDecoder  
File Role Description
  Plain text file JsonBinaryDecoderException.php Class Class source
  Plain text file JsonBinaryDecoderFormatter.php Class Class source
  Plain text file JsonBinaryDecoderService.php Class Class source
  Plain text file JsonBinaryDecoderValue.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Repository  
File Role Description
  Plain text file FieldDTO.php Class Class source
  Plain text file FieldDTOCollection.php Class Class source
  Plain text file MasterStatusDTO.php Class Class source
  Plain text file MySQLRepository.php Class Class source
  Plain text file PingableConnection.php Class Class source
  Plain text file RepositoryInterface.php Class Class source

  Files folder image Files  /  src  /  MySQLReplication  /  Socket  
File Role Description
  Plain text file Socket.php Class Class source
  Plain text file SocketException.php Class Class source
  Plain text file SocketInterface.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageIntegration (3 files)
Files folder imageUnit (1 file, 6 directories)
  Accessible without login Plain text file bootstrap.php Test Unit test script

  Files folder image Files  /  tests  /  Integration  
File Role Description
  Plain text file BaseTest.php Class Class source
  Plain text file BasicTest.php Class Class source
  Plain text file TestEventSubscribers.php Class Class source

  Files folder image Files  /  tests  /  Unit  
File Role Description
Files folder imageBinaryDataReader (1 file)
Files folder imageCache (1 file)
Files folder imageConfig (1 file)
Files folder imageEvent (1 directory)
Files folder imageGtid (2 files)
Files folder imageRepository (1 file)
  Accessible without login Plain text file BaseTest.php Test Unit test script

  Files folder image Files  /  tests  /  Unit  /  BinaryDataReader  
File Role Description
  Accessible without login Plain text file BinaryDataReaderTest.php Test Unit test script

  Files folder image Files  /  tests  /  Unit  /  Cache  
File Role Description
  Plain text file ArrayCacheTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Config  
File Role Description
  Plain text file ConfigTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Event  
File Role Description
Files folder imageRowEvent (1 file)

  Files folder image Files  /  tests  /  Unit  /  Event  /  RowEvent  
File Role Description
  Plain text file TableMapTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Gtid  
File Role Description
  Accessible without login Plain text file GtidCollectionTest.php Test Unit test script
  Accessible without login Plain text file GtidTest.php Test Unit test script

  Files folder image Files  /  tests  /  Unit  /  Repository  
File Role Description
  Plain text file MySQLRepositoryTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:755
This week:0
All time:4,451
This week:108Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:95%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:91%StarStarStarStarStar
Videos:-
Overall:87%StarStarStarStarStar
Rank:2