Download the PHP package accordsync/server without Composer

On this page you can find all versions of the php package accordsync/server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package server

accordsync/server

The Accord sync server for PHP, on PostgreSQL.

A framework-agnostic PSR-15 request handler for GET /health, POST /v1/push and GET /v1/pull: push and pull, scopes, JWT auth, limits, rate limits, CORS and compaction. It speaks the same protocol, merges by the same rules and uses the same PostgreSQL schema as @accordsync/server, so the TypeScript, React Native, Flutter and Python clients sync with it unchanged.

In a Laravel or Symfony app, use accordsync/laravel or accordsync/symfony: they wire this package into the framework (routes, config, database connection, cache, console commands). This page is for plain PHP, or for another framework.

Install

PHP 8.3+ with pdo_pgsql, and PostgreSQL (the conformance suite and the example apps use PostgreSQL 16). The handler needs a PSR-7/PSR-17 implementation; the example below uses nyholm/psr7 and nyholm/psr7-server.

Define the server

AccordServer::define() takes the same parts as defineServer in TypeScript: the schema, a scope function per record type, the access a user gets from their JWT claims, and how tokens are checked. It checks at once that every record type has a scope function. Keep the definition in a file that returns it, so the front controller and vendor/bin/accord compact share it:

Optional arguments: cors (browser origins allowed to call the API), rateLimit (a RateLimits; default 600 requests a minute per device and 1 800 per user; false turns it off), compaction (a Compaction: device TTL, interval, minimum ops) and limits (a Limits: body size, ops per push, pull page size, scope delta size, clock skew). Auth::hs256($secret) is for development and tests.

Serve it

AccordServer::handler() returns a Psr\Http\Server\RequestHandlerInterface. It routes on the request path, so mount it where the path it sees is /health, /v1/push or /v1/pull.

ACCORD_DATABASE_URL is a URL like postgres://user:password@host:5432/db. Each PHP worker handles one request at a time, so the worker pool size bounds concurrent pushes.

Migrations and compaction

Run accord compact from cron at the definition's compaction.intervalMs (default hourly). It takes PostgreSQL's exclusive advisory lock, so overlapping runs, or several servers, do not conflict. In code: AccordServer::migrate($pdo) and AccordServer::compact($definition, $pdo).

One database, any Accord server

The migrations are the TypeScript server's, recorded in the same ledger table (kysely_migration): a database migrated by @accordsync/server is up to date here, and the other way round. One database can be served by TypeScript and PHP servers at the same time, with clients sent to either. The repository's interop/ harness does exactly that: TypeScript devices send every request to a randomly chosen server, through a network that loses requests and responses, and must end with identical data. The repository's Laravel and Symfony example apps also pass Accord's black-box HTTP conformance suite, the same one the TypeScript server passes.

Security notes

Docs: accord.benhattab.pro/docs/php · Source: crossben/accordsync-php · Licence: Apache-2.0


All versions of server with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
accordsync/core Version ^0.3
ext-pdo_pgsql Version *
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
firebase/php-jwt Version ^7.2
psr/http-factory Version ^1.0
psr/simple-cache Version ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package accordsync/server contains the following files

Loading the files please wait ...