Download the PHP package surrealdb/laravel without Composer
On this page you can find all versions of the php package surrealdb/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel
SurrealDB Laravel
Laravel integration for the official SurrealDB PHP SDK and the Surqlize ORM.
This package gives Laravel applications a publishable configuration file, service-container bindings, facades, an Artisan schema command, and testing helpers. Query execution and database protocol behavior are delegated to surrealdb/surrealdb.php; ORM models, query compilation, graph relations, and schema definitions are delegated to surqlize/surqlize.
Requirements
| Requirement | Version |
|---|---|
| PHP | >=8.4 |
| Laravel components | ^11.0, ^12.0 or ^13.0 |
| Surqlize | surqlize/surqlize dev-main |
| SurrealDB PHP SDK | surrealdb/surrealdb.php 2.0.0-alpha.0 |
Installation
Install the package with Composer:
While the SDK and ORM are still in active development, local workspace installs can use path repositories:
Publish the configuration:
Configuration
The package intentionally keeps SDK and ORM configuration separate:
config/surrealdb.phpconfigures the raw SurrealDB PHP SDK client.config/surqlize.phpconfigures Surqlize ORM behavior.
config/surrealdb.php reads these common environment variables:
If SURREALDB_USERNAME is set, the package uses SDK RootAuth by default. For scoped authentication, set SURREALDB_AUTH_MODE to namespace, database, record, bearer, token, or none, then fill the matching keys in the published config.
The SDK config supports named connections:
config/surqlize.php contains the ORM model list and executor binding:
Service Container
Laravel auto-discovers two service providers:
SurrealDB\Laravel\SurrealDBServiceProviderowns SDK configuration, client construction, and thesurrealdbcontainer alias.SurrealDB\Laravel\SurqlizeServiceProviderowns ORM configuration, schema commands, Surqlize's executor binding, andConnectionManagersetup.
The SDK provider binds:
SurrealDB\SDK\Surrealand thesurrealdbcontainer alias for the raw SDK client.SurrealDB\Laravel\SurrealDBManagerplus thesurrealdb.managerandsurrealdb.connectionaliases for Laravel-style lifecycle helpers.
The ORM provider binds:
SurrealDB\SDK\Contracts\QueryExecutorfor Surqlize query execution.Surqlize\Model\SchemaManagerfor schema definitions and application.SurrealDB\Laravel\SurqlizeManagerand thesurqlizecontainer alias for Laravel-friendly helpers.
The ORM provider also registers Surqlize's global ConnectionManager with a lazy executor that resolves the configured surqlize.executor binding only when a query executes. By default, that binding points at surrealdb.connection, so Surqlize model queries use the Laravel manager and connect lazily.
Models
Surqlize models are not Eloquent models. They extend Surqlize\Model\Model and use Surqlize attributes:
Register models that should participate in schema commands:
Schemas
Schemas implement Surqlize\Model\SchemaContract:
Preview schema statements:
Apply schema statements:
Queries
Use Surqlize's model APIs:
No manual executor is needed for normal Laravel usage. The package configures Surqlize to use the Laravel-managed SurrealDB executor:
Use the raw SDK when you need lower-level access:
Use the Laravel manager facade when you want lifecycle helpers around the same SDK client:
The Surqlize facade exposes schema and transaction helpers:
Surqlize::transaction() uses Surqlize's executor-based SurrealQL transaction batching. SDK-native transaction IDs are not exposed through the Laravel facade yet because they depend on WebSocket transport and server feature support.
Testing
Use the package testing trait to reset Surqlize's global caches:
For unit tests, pass a fake QueryExecutor to Surqlize queries or call useSurqlizeExecutor() from the trait.
You can also fake the Laravel-managed executor:
Named fakes are scoped by connection:
Development
Notes
- The SDK v2 API is still alpha, so expect dependency constraints to tighten as the SDK stabilizes.
- Laravel singleton scope follows the application container: normally once per request under PHP-FPM, and longer-lived under Octane, queue workers, or long-running commands.
- Surqlize currently has a singleton
ConnectionManager. Use per-querywithExecutor()or explicitexecutor:arguments when you need multiple executors in the same process. - Live queries, sessions, and native SDK transactions require WebSocket support and depend on the underlying SurrealDB server version.
All versions of laravel with dependencies
illuminate/console Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
surrealdb/surqlize Version 0.0.1-alpha.2
surrealdb/surrealdb.php Version 2.0.0-alpha.1