• Start

Languages

/

PHP

/

Methods

signin

The ->signin() method for the SurrealDB SDK for PHP signs in to a specific access method.

Signs in to a root, namespace, database or record user.

Method Syntax

$db->signin([
"namespace" => "test",
"database" => "db",
"access" => "account",
// ... other variables
]);
PropertiesDescription
username The username of the database user
password The password of the database user
namespace The namespace to sign in to
database The database to sign in to
access The access method to sign in to. Also pass any variables used in the access definition.
// Authenticate with a root user
$token = $db->signin([
"username" => "root",
"password" => "surrealdb",
]);

// Authenticate with a Namespace user
$token = $db->signin([
"namespace" => "surrealdb",
"username" => "tobie",
"password" => "surrealdb",
]);

// Authenticate with a Database user
$token = $db->signin([
"namespace" => "surrealdb",
"database" => "docs",
"username" => "tobie",
"password" => "surrealdb",
]);

// Authenticate with a record access user
$token = $db->signin([
"namespace" => "surrealdb",
"database" => "docs",
"access" => "user",

// Also pass any properties required by the access definition
"email" => "info@surrealdb.com",
"pass" => "123456",
]);

You can invalidate the authentication for the current connection using the invalidate() method.

Was this page helpful?