Download the PHP package accordsync/laravel without Composer
On this page you can find all versions of the php package accordsync/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download accordsync/laravel
More information about accordsync/laravel
Files in accordsync/laravel
Package laravel
Short Description Accord sync server for Laravel: service provider, config, routes and artisan commands.
License Apache-2.0
Homepage https://accord.benhattab.pro
Informations about the package laravel
accordsync/laravel
The Accord sync server inside a Laravel app: a service provider,
config/accord.php, the sync routes, php artisan accord:migrate / accord:compact, and compaction
in the scheduler. All sync behaviour comes from accordsync/server; this package only
wires it in. Laravel 11+ (tested with 13), PHP 8.3+, PostgreSQL.
Install
The provider is auto-discovered.
Declare the server
config/accord.php points at your definition: what AccordServer::define() returns (schema, a scope
function per record type, access from JWT claims, auth, limits). Use an invokable class so that
php artisan config:cache keeps working; its __invoke() parameters are injected by the container.
A closure returning the definition also works, but closures cannot be cached by config:cache.
Configuration
| Key | Env | Default | |
|---|---|---|---|
definition |
ACCORD_DEFINITION |
none | class name or closure (above) |
prefix |
ACCORD_PREFIX |
accord |
routes are /{prefix}/health, /{prefix}/v1/push, /{prefix}/v1/pull; clients use https://your-app/{prefix} as their server URL. Empty: served at the root |
middleware |
[] |
extra route middleware (keep it stateless) | |
database.url |
ACCORD_DATABASE_URL |
none | postgres://user:password@host:5432/db: Accord opens its own persistent connection |
database.connection |
ACCORD_DB_CONNECTION |
default connection | otherwise the PDO of this Laravel connection, which must use the pgsql driver |
rate_limit.store |
ACCORD_RATE_LIMIT_STORE |
default store | cache store holding the rate-limit buckets; it must support atomic locks |
schedule |
ACCORD_SCHEDULE |
true |
register accord:compact with the scheduler |
Run
Serve the app as usual (PHP-FPM, FrankenPHP...). Each PHP worker handles one request at a time, so the worker pool size bounds concurrent pushes.
Use a persistent database connection ('options' => [PDO::ATTR_PERSISTENT => true] on the pgsql
connection, or ACCORD_DATABASE_URL, which is always persistent). Otherwise every sync request opens
a PostgreSQL connection, about 10 ms with SCRAM authentication. Laravel also runs set names and
set search_path when it opens a connection, persistent or not, if the connection config has
charset or search_path: leave them out when the database defaults are right.
Compaction
php artisan accord:compact runs compaction once. When the definition's compaction.intervalMs is
above 0 (default one hour) and schedule is on, the provider registers accord:compact with
Laravel's scheduler (withoutOverlapping(); intervals are rounded to whole minutes under an hour,
whole hours above), so the usual * * * * * php artisan schedule:run cron entry runs it. Compaction
takes PostgreSQL's exclusive advisory lock, so two servers compacting at once do not conflict.
Security notes
- The routes are outside the
webmiddleware group: no session, cookies or CSRF token. Requests authenticate withAuthorization: Bearer <jwt>checked by the definition'sauth(JWKS with issuer and audience in production;Auth::hs256()is for development and tests). Laravel guards (Sanctum, sessions) are not used (ADR-P03). - Don't add the Accord paths to
config/cors.php: CORS for the sync API is the definition'scorslist, answered by the handler. - Rate limits are as shared as the cache store:
fileworks on one host; use Redis (or another shared store with locks) on several. Thearraystore does not limit anything across requests. - Request bodies above the definition's
maxBodyBytesget 413 from the handler; PHP's ownpost_max_sizestill applies before it.
The tested setup is examples/laravel-app, which passes the Accord
server conformance suite (68 tests) in CI; see docs/adr/0010-example-apps-and-serving.md.
All versions of laravel with dependencies
accordsync/server Version ^0.3
illuminate/support Version ^11.0 || ^12.0 || ^13.0
illuminate/console Version ^11.0 || ^12.0 || ^13.0
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/http Version ^11.0 || ^12.0 || ^13.0
illuminate/routing Version ^11.0 || ^12.0 || ^13.0
illuminate/cache Version ^11.0 || ^12.0 || ^13.0
nyholm/psr7 Version ^1.8