Download the PHP package hub-io/laravel-hubio-sync without Composer
On this page you can find all versions of the php package hub-io/laravel-hubio-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hub-io/laravel-hubio-sync
More information about hub-io/laravel-hubio-sync
Files in hub-io/laravel-hubio-sync
Package laravel-hubio-sync
Short Description Backup, sharing and photo synchronization of Hubio NativePHP apps through Hubio.Space (api/sync/v1/{app}).
License MIT
Homepage https://github.com/hub-io/laravel-hubio-sync
Informations about the package laravel-hubio-sync
Laravel Hubio Sync
Offline-first backup, sharing and photo synchronization for NativePHP Mobile apps through the Hubio.Space sync API (api/sync/v1/{app}).
The app keeps working on its local SQLite database. In the background the device registers anonymously (its personal household is the backup), can create or join family / work households with an invite code, and exchanges changed rows with the server: pending rows, photos and deletions go up, rows changed by other devices come down. The newest change of a row wins on both sides.
Support us
We invest a lot of time and give our hearts to work in Open Source.
Requirements
- PHP 8.3+
- Laravel 13
- nativephp/mobile 4.6+
- Optional:
nativephp/mobile-secure-storage(device token in the keychain) andnativephp/mobile-firebase(push-triggered sync)
Installation
You can install the package via composer:
The migrations (households, sync_tombstones, sync_files) are loaded automatically:
You can publish the config file with:
This is the content of the published config file:
Set the API URL of your app in .env. An empty URL turns synchronization off and the app works offline only:
Usage
Make a model syncable
The table needs a uuid column, a synced_at string column and timestamps. Timestamps keep milliseconds (the newest change wins); a row whose updated_at differs from synced_at is pending upload, and a deleted row leaves a tombstone.
Register it in config/hubio-sync.php, referenced rows first:
Optional hooks on the model:
| Method | Purpose |
|---|---|
syncHouseholds(): array |
Households the row belongs to (defaults to the personal backup). |
syncDependencies(): array |
Rows that must reach the same shared household (e.g. an item's product). |
syncFiles(): array |
Payload keys holding photos => column with the path on the files disk. |
static syncExisting(array $attributes): ?int |
Local row a downloaded record with a new UUID merges into. |
static syncApplied(int $id, array $data, Household $household): void |
Writes child rows of a downloaded record (use the query builder). |
Synchronize
Saving or deleting a syncable model starts a background sync shortly after (bursts of changes start one task). While a screen is open, poll periodically:
Or run it in the foreground:
The status is one of disabled, offline, failed or synced. SyncClient::state() returns the last sync time and error.
Households
Shares
Publish a record under a code for everyone using the same app; others open it and rate it with 1–5 stars:
Push-triggered sync
With nativephp/mobile-firebase, the push token is sent to the server automatically. When a household changes, Hubio.Space sends a silent data message with the event Hubio\Sync\Events\SyncRequested, which runs a sync, also while the app is in the background.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Hubio s.r.o.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.