Skip to navigation

PHP SDK

The Partner API, events and webhooks for PHP, with optional Laravel integration.

Requirements

RequirementDetail
PHP8.3 or later — supported 8.3, 8.4, 8.5 and 8.6; 8.5 recommended
Required extensionsext-hash, ext-json, ext-openssl
mbstringProvided automatically by the symfony/polyfill-mbstring dependency — a no-op where ext-mbstring is installed. It is needed because the official PHP 8.6 image ships without mbstring.
Optionalext-pdo (the durable PDO checkpoint and dedup stores), ext-pcntl (graceful shutdown of long-running consumers), a PSR-18 HTTP client — Guzzle or Symfony HttpClient

With Guzzle or Symfony HttpClient installed, the SDK builds the HTTP client itself, with timeouts and redirects disabled (a redirect could carry your token to another origin; the API never redirects). With any other PSR-18 client, timeouts and redirects are that client’s configuration.

Install

Coming at general availability. Until then, this page shows the requirements and how the SDK is used.

Configure

client.php
use Evva\Partner\Auth\ClientCredentials;
use Evva\Partner\PartnerClient;
$evva = new PartnerClient(
baseUrl: 'https://api.evvahub.com',
credentials: ClientCredentials::secretBasic(getenv('EVVA_CLIENT_ID'), getenv('EVVA_CLIENT_SECRET')),
);
Other client authentication
ClientCredentials::secretPost($clientId, $secret);
ClientCredentials::privateKeyJwt($clientId, file_get_contents('/run/secrets/evva.pem'), 'key-2026-12', AssertionAlgorithm::ES256);

Several PHP processes (FPM workers, queue workers, cron) can share one token: pass a PSR-16 cache as tokenCache: (Redis, APCu, Laravel’s cache). It stores a bearer token, so use a private store.

First calls

first-calls.php
$me = $evva->app->me(); // applicationId names the realtime channel
foreach ($evva->accounts->iterate() as $creator) { // creators granted to this application
$page = $evva->conversations->list($creator->creatorId, limit: 20);
}
$evva->messages->sendText($creatorId, $conversationId, 'Hello!'); // AI_AUTOMATED, with an Idempotency-Key

Receive events

consumer.php
$consumer = $evva->feedConsumer('crm-sync', function (PartnerEvent $event, EventContext $ctx) { /* … */ },
checkpointStore: new PdoCheckpointStore($pdo), dedupStore: new PdoDedupStore($pdo));
$consumer->run(); // long-running; SIGTERM/SIGINT finish the in-flight event, checkpoint, exit
$consumer->drain(); // or: catch up once and return (cron, replay)

$evva->eventStream(…) combines realtime (WebSocket) with the feed: one handler, one dedup store, and a feed catch-up after any gap. ServerCheckpointStore uses the API’s consumer groups, so several workers share one position. Stores: InMemory* (tests only), File* (one host), Pdo* (SQLite, MySQL/MariaDB, PostgreSQL).

The PHP SDK speaks WebSocket only — PHP has no maintained WebTransport client. The semantics are identical.

Errors

All exceptions extend EvvaException; API errors carry status, requestId and details.

ExceptionWhen
ValidationException400, 422
AuthException401
PermissionException403
NotFoundException404
ConflictException, IdempotencyConflictException409 — also LeaseHeldException, StaleFencingTokenException, ConversationAdvancedException, AutomationPausedException
CursorExpiredException410 CURSOR_EXPIRED
RateLimitedException429 — retryAfterSeconds, level()
ServerException, NetworkException5xx, no response
ApprovalRequiredException202 APPROVAL_REQUIRED — re-send with RequestOptions::approved($e->approvalId, $e->idempotencyKey) once approved; see Approvals

Webhooks

webhook.php
$handler = new WebhookHandler([$currentSecret, $previousSecret], function (PartnerEvent $event) { /* enqueue */ },
new FileDedupStore('/var/lib/my-app/evva-dedup.log')); // durable: survives a restart
$result = $handler->handle($headers, $rawBody);
http_response_code($result->status);

WebhookVerificationMiddleware (PSR-15) and the Laravel evva.webhook middleware answer the same statuses and deduplicate the same way.

Laravel

An optional integration ships a service provider, the EvvaPartner alias (a Laravel Facade), configuration, the webhook middleware and a feed-consumer command. It is used only when laravel/framework is installed.

Next steps