https://github.com/umbrellio/php-table-sync
PHP's implementation of the library providing data synchronization between microservices
https://github.com/umbrellio/php-table-sync
Last synced: 11 months ago
JSON representation
PHP's implementation of the library providing data synchronization between microservices
- Host: GitHub
- URL: https://github.com/umbrellio/php-table-sync
- Owner: umbrellio
- License: mit
- Created: 2020-12-26T16:44:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T18:21:09.000Z (over 1 year ago)
- Last Synced: 2025-06-07T04:06:24.236Z (about 1 year ago)
- Language: PHP
- Size: 89.8 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP TableSync
###### PHP's implementation of the library providing data synchronization between microservices
[](https://github.com/umbrellio/php-table-sync/actions)
[](https://coveralls.io/github/umbrellio/php-table-sync?branch=master)
[](https://packagist.org/packages/umbrellio/php-table-sync)
[](https://packagist.org/packages/umbrellio/php-table-sync)
[](https://scrutinizer-ci.com/code-intelligence)
[](https://scrutinizer-ci.com/g/umbrellio/php-table-sync/build-status/master)
[](https://scrutinizer-ci.com/g/umbrellio/php-table-sync/?branch=master)
[](https://scrutinizer-ci.com/g/umbrellio/php-table-sync/?branch=master)
## Installation
```shell
composer require umbrellio/php-table-sync
php artisan vendor:publish --tag=config-table-sync
```
## Usage
Let's describe the model that needs to be synchronized using an example `User.php`
```php
...
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,
];
}
...
```
When the model changes, the data will be sent according to the rules of `TableSyncObserver`, to get the data you need to run the command `table_sync:work`
## Logging
Logging based on the Monolog package and contains some extensions for it.
- specify the logging channel in `config/table_sync.php`
```php
...
'log' => [
'channel' => 'table_sync',
],
...
```
- and describe this channel in `config/logging.php`
```php
...
'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',
],
...
```
##### You can use the built-in `LineTableSyncFormatter::class` with the available parameters: `%datetime%` `%message%` `%direction%` `%model%` `%event%` `%routing%` `%attributes%` `%exception%`
###### Driver `influxdb` is an additional option and is not required to add in config
```php
...
'table_sync' => [
'driver' => 'daily',
],
...
```
## Authors
Created by Korben Dallas.