1. Go to this page and download the library: Download b2pweb/bdf-prime-events 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/ */
use Bdf\PrimeEvents\EntityEventsConsumer;
use MySQLReplication\Config\ConfigBuilder;
$consumer = new EntityEventsConsumer(
$prime, // The ServiceLocator instance
__DIR__.'/mysql_last_event.log', // File for store the last consumed event, to allow restart without loosing events
function (ConfigBuilder $config) {
$config
// Define custom connection configuration
// Note: by default, the connection user and password is used
// So it's not The entity has been updated. $before is its value before the update, and $now the current value */ })
->deleted(function (MyEntity $entity) { /* $entity has been deleted */})
;
// Other entities may be configure...
// Consume all events
// Note: consume() will only consume 1 event
while ($running) {
$consumer->consume();
}
// Stop the consumer and save the last consumed events
$consumer->stop();
use Bdf\PrimeEvents\Factory\EntityEventsListenerInterface;
/**
* @implements EntityEventsListenerInterface<MyEntity>
*/
class MyEntityListeners implements EntityEventsListenerInterface
{
/**
* {@inheritdoc}
*/
public function entityClass() : string
{
return MyEntity::class;
}
/**
* {@inheritdoc}
* @param MyEntity $entity
*/
public function onInsert($entity) : void
{
// $entity has been inserted
}
/**
* {@inheritdoc}
* @param MyEntity $oldEntity
* @param MyEntity $newEntity
*/
public function onUpdate($oldEntity, $newEntity) : void
{
// The entity has been updated.
// $before is its value before the update, and $now the current value
}
/**
* {@inheritdoc}
* @param MyEntity $entity
*/
public function onDelete($entity) : void
{
// $entity has been deleted
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.