PHP code example of umbrellio / php-table-sync

1. Go to this page and download the library: Download umbrellio/php-table-sync 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/ */

    

umbrellio / php-table-sync example snippets


...
User extends Model implements SyncableModel
{
    use TableSyncable;

...

    public function routingKey(): string
    {
        return 'users';
    }

    public function getTableSyncableAttributes(): array
    {
        return [
            'id' => $this->external_id,
            'login' => $this->name,
            'email' => $this->email,
        ];
    }
...

...
'log' => [
    'channel' => 'table_sync',
],
...

...
'table_sync' => [
    'driver' => 'stack',
    'channels' => ['table_sync_daily', 'influxdb'],
],
'table_sync_daily' => [
    'driver' => 'daily',
    'formatter' => LineTableSyncFormatter::class,
    'formatter_with' => [
        'format' => '[%datetime%] %message% - %model% %event%',
    ],
    'path' => storage_path('logs/table_sync/daily.log'),
],
'influxdb' => [
    'driver' => 'influxdb',
    'measurement' => 'table_sync',
],
...

...
'table_sync' => [
    'driver' => 'daily',
],
...
shell
composer endor:publish --tag=config-table-sync