Skip to content

boone-studios/laravel-surrealdb

Repository files navigation


SurrealDB for Laravel


Latest Version on Packagist Total Downloads GitHub Actions

Overview

This package allows you to add a connection to SurrealDB in your Laravel project.

Installation

You can install the package via Composer:

composer require boone-studios/laravel-surrealdb

Usage

Laravel

If you are using an older version of Laravel that doesn't support autoloading packages, add the service provider to config/app.php:

BooneStudios\Surreal\SurrealServiceProvider::class

Lumen

Add the service provider to bootstrap/app.php in your project.

$app->register(BooneStudios\Surreal\SurrealServiceProvider::class);

Configuration

To configure a new SurrealDB connection, add a new connection entry to config/database.php:

'surrealdb' => [
    'driver' => 'surrealdb',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', 8000),
    'namespace' => env('DB_NAMESPACE', 'laravel'),
    'database' => env('DB_DATABASE', 'app'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', 'root'),
],

Regarding the namespace parameter, from the SurrealDB documentation:

SurrealDB has a multi-tenancy model which allows you to scope databases to a namespace. There is no limit to the number of databases that can be in a namespace, nor is there a limit to the number of namespaces allowed. Only users root users are authorized to create namespaces.

Let's say that you're using SurrealDB to create a multi-tenant SaaS application. You can guarantee that the data of each tenant will be kept separate from other tenants if you put each tenant's databases into separate namespaces. In other words, this will ensure that information will remain siloed so user will only have access the information in the namespace they are a member of.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email support@boonestudios.org instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Star History

Star History Chart