1. Go to this page and download the library: Download ottimis/ermes-php-sdk 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/ */
ottimis / ermes-php-sdk example snippets
use Ottimis\Ermes\NotificationConfig;
use Ottimis\Ermes\NotificationClient;
$config = new NotificationConfig(
coreUrl: 'https://ermes.yourcompany.com',
tenantKey: 'myapp',
applicationId: 'my-backoffice',
issuer: 'https://auth.yourcompany.com',
apiKey: 'ak_xxxxxxxxxxxxxxx', // from POST /api/v1/admin/tenants
apiSecret: 'as_yyyyyyyyyyyyyyy', // from POST /api/v1/admin/tenants
privateKeyPem: file_get_contents('/path/to/private.pem'),
kid: 'myapp-key-1',
);
$client = new NotificationClient($config);
$client = new NotificationClient(NotificationConfig::fromEnv());
// GET /.well-known/jwks.json
$client->getJwks(); // returns the JWKS array
$result = $client->sendEvent([
'topic' => 'contract.termination.completed',
'title' => 'Cessazione completata',
'body' => "La cessazione del contratto C-1234 è stata elaborata.",
'severity' => 'info', // info | warning | error | success
'entity_type' => 'contract', // optional
'entity_id' => 'C-1234', // optional
'recipient_users' => ['user_42'], // array of user IDs (1–500)
'payload' => ['contract_id' => 'C-1234'], // optional custom JSON
]);
// $result['success'] — true if core returned 202
// $result['core_status'] — HTTP status from core
// $result['body'] — decoded response body
// Short form — token string only
$token = $client->createUserToken('user_42');
// Full form — token + claims (use info.exp to know expiry)
$result = $client->createUserTokenWithInfo('user_42');
// $result['token'] — JWT string
// $result['info']['exp'] — Unix timestamp, token valid for 1 hour
// $result['info']['tenant_id'], ['iss'], ['aud'], ['sub'], ['iat']
// Custom roles (default: ['operator'])
$token = $client->createUserToken('user_42', ['operator', 'admin']);
$result = $client->syncNotifications('user_42', [
'after' => 'notif_1250', // cursor from previous sync response
'limit' => 50, // 1–200 (default: 50)
]);
// $result['body']['items'] — new items since cursor
// $result['body']['cursor'] — new cursor for next sync, null if no more
// Single
$client->markAsRead('1b2c3d4e-5f60-4718-9abc-def012345678', 'user_42');
// Bulk (up to 200 UUIDs)
$client->markBulkRead([
'1b2c3d4e-5f60-4718-9abc-def012345678',
'2c3d4e5f-6071-4829-abcd-ef0123456789',
], 'user_42');
// All unread
$client->markAllAsRead('user_42');
$result = $client->sendEvent([...]);
if (!$result['success']) {
// $result['core_status'] — HTTP status (400, 401, 429, 500, ...)
// $result['body']['error'] — error code string
// $result['body']['details'] — validation details (on 400)
}