1. Go to this page and download the library: Download pushinbr/pam-native-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/ */
pushinbr / pam-native-sync example snippets
use Pam\Native\Sync\SyncEngine;
use Pam\Native\Sync\Transport\HttpSyncTransport;
$transport = new HttpSyncTransport(
endpoint: 'https://api.example.com/sync',
clientIdentifier: $deviceId,
tokenProvider: fn (): ?string => $session->accessToken(),
);
$engine = new SyncEngine($store, $transport);
$engine = new Pam\Native\Sync\SyncEngine(
new Pam\Native\Sync\Storage\SQLiteSyncStore(),
$transport,
new Pam\Native\Sync\PolicyConflictResolver(Pam\Native\Sync\ConflictPolicy::LastWriteWins),
);
$engine->upsert('todos', 'todo-42', ['title' => 'Ship'], 7, fn ($operation) => null);
$engine->synchronize(fn (Pam\Native\Sync\SyncRunReport $report) => null);
$clock = new Pam\Native\Sync\Crdt\HybridLogicalClock($deviceId);
$document = new Pam\Native\Sync\Crdt\LastWriteWinsMap();
$document->assign('title', 'Offline edit', $clock->tick());
// Exchange snapshots through any transport, then merge in either order.
$remote = Pam\Native\Sync\Crdt\LastWriteWinsMap::restore($payload);
$document->merge($remote);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.