Skip to main content
The PHP SDK is a thin FFI wrapper around the native Rust control client. It keeps feature parity with the other control clients (create, apply, patch, archive / restore, list, events, get, select, verify) while negotiating Noise + Cap’n Proto frames directly against the control socket. Defaults come from EVENTDBX_* environment variables, so you can drop it into Laravel, Symfony, or plain PHP services.

Feature highlights

  • Native control-socket client over Noise XX + Cap’n Proto with parity to other SDKs (create, apply, patch, archive / restore, list, events, get, select, verify).
  • Publish targets and per-call token overrides on mutations; payload/metadata/note fields accept any JSON-serializable data.
  • Pagination helpers for aggregates and events with take, cursor, and filtering/sorting by aggregate type.
  • Defaults for host/port/token/tenant pulled from EVENTDBX_*; configure timeouts and Noise on/off flags per client.
  • PHP 8.1+ with the ffi extension; no PSR HTTP client required because it talks to the control socket directly.

Install

Build the native library before running the client:
cd vendor/eventdbx/eventdbx-php/native
cargo build —release
The client will auto-load native/target/release/libeventdbx_php_native.(so|dylib|dll). Ensure FFI is allowed for your SAPI (ffi.enable=preload in php.ini, and add the built library path to ffi.preload if your environment restricts dynamic loads).

Quickstart

Publish targets

Omit publish targets to fan out to all enabled plugins. Specs follow plugin with optional mode and priority.

Write aggregates and events

create seeds the aggregate and its first event atomically; apply appends events; patch issues RFC 6902 operations against prior payloads; archive/restore toggle write access while preserving history.

Read aggregates and events

Pagination responses include items and nextCursor; pass cursor back to keep paging. Filters and sorts follow the control-plane syntax (e.g., aggregate_type = "person" is added automatically when listing a specific type).

Runtime configuration

Additional constructor options (all optional): protocol_version, connect_timeout_ms, request_timeout_ms, tenantId, and noNoise.

Noise transport

Noise is enabled by default with a PSK derived from the control token. Only disable it for controlled testing by passing ['noNoise' => true] to the client config or setting EVENTDBX_NO_NOISE=1; production deployments should keep Noise on.

Development & testing

Build the native library once per platform so PHP can load it via FFI, then run the PHPUnit suite. Ensure ffi.enable is permitted in your PHP SAPI and restart PHP-FPM after changing php.ini.