PHP code example of accordsync / laravel
1. Go to this page and download the library: Download accordsync/laravel 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/ */
accordsync / laravel example snippets
// config/accord.php
'definition' => App\Accord\Definition::class,
namespace App\Accord;
use Accord\Core\Schema;
use Accord\Server\{Access, AccordServer, Auth, ScopedRecord, ServerDefinition};
use Illuminate\Contracts\Cache\Repository;
final class Definition
{
public function __invoke(Repository $cache): ServerDefinition
{
return AccordServer::define(
schema: Schema::define(['dossier' => ['agent' => Schema::lww(), 'visits' => Schema::counter()]]),
scopes: ['dossier' => fn (ScopedRecord $r) => ScopedRecord::key('agent', $r->fields['agent'] ?? null)],
access: fn (array $claims) => new Access(read: ["agent:{$claims['sub']}"], write: ["agent:{$claims['sub']}"]),
// The JWKS is cached in Laravel's cache, shared by every worker.
auth: Auth::jwks('https://auth.example.com/.well-known/jwks.json', issuer: 'https://auth.example.com/', audience: 'accord', cache: $cache),
);
}
}