Version 2 is a rewrite of the PHP SDK. It keeps the same goal as v1, connecting your PHP application to SurrealDB, but changes most of the public surface. Queries are built with a fluent builder ($db->select($table)->where(...)->limit(10)), credentials are typed value objects, and the transport layer is built on PSR HTTP interfaces so you can swap in your own client.
Version 2 is published as 2.0.0-alpha.1. It is an alpha with breaking changes against v1, and the public API may still change before a stable release. Pin the exact version when installing.
These docs are a work in progress. While the SDK is in alpha, expect them to change substantially as decisions about the public-facing API are settled.
The SDK requires PHP 8.4 or later and works with SurrealDB server versions 1.0.0 up to (but not including) 4.0.0. The version is checked on connect unless you disable it.
If you are upgrading an existing project, start with the migration guide.
Getting started
Core concepts
Connecting to SurrealDB
Open a connection over WebSocket or HTTP, select a namespace and database, and handle reconnection.
Authentication
Sign in and sign up with typed credentials, then manage tokens.
Executing queries
Run raw SurrealQL or use the fluent query builders for select, create, update, and delete.
Live queries
Subscribe to real-time changes over a WebSocket connection.