Oihana PHP Arango

ArangoClientTrait uses trait:short

Best-effort ArangoDB HTTP client builder for the `command:arangodb` actions.

The dump / restore actions talk to the database through the arangodump / arangorestore binaries (a shell-out that does not need the HTTP API). This trait provides an optional, non-fatal bridge to the HTTP client so an action can additionally query the live database — e.g. to list or validate collection names before a targeted dump.

It is deliberately forgiving: buildDatabase() returns null (instead of throwing) when no usable endpoint is configured or the client cannot be constructed, so callers can degrade gracefully and let the underlying binary keep working when the HTTP API is unavailable.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$database  : string|null
The ArangoDB database name.
$endpoint  : string|null
The ArangoDB database endpoint.
$password  : string|null
The ArangoDB database password.
$username  : string|null
The ArangoDB database username.

Methods

assertDatabase()  : void
Assert the database reference.
assertEndpoint()  : void
Assert the passed-in endpoint reference.
assertPassword()  : void
Assert the passed-in password reference.
assertUsername()  : void
Assert the passed-in username reference.
getDatabase()  : string
Returns the database name and asserts the existence of the value.
getEndpoint()  : string
Returns the database endpoint and throws an error if not set.
getPassword()  : string
Returns the database password and throws an error if not set.
getUsername()  : string
Returns the database username and throws an error if not set.
initializeArangoDB()  : static
Initialize the arangodb components.
buildDatabase()  : Database|null
Builds a best-effort {@see Database} HTTP client from the resolved connection settings, or null when no usable endpoint/database is available or the client cannot be constructed.
resolveDatabase()  : Database|null
Builds the best-effort {@see Database} HTTP client of an action run: every connection setting reads its CLI option first (`--database` / `--endpoint` / `--user` / `--password`) and falls back on the command configuration ({@see ArangoConfigTrait}).
resolveFacade()  : ArangoDB|null
Builds the best-effort high-level {@see ArangoDB} façade of an action run, from the same resolved connection settings as {@see resolveDatabase()} — the migration engine hands this façade to every {@see \oihana\arango\migrations\Migration}. Null when no usable endpoint is configured or the façade cannot be constructed.

Properties

$database

The ArangoDB database name.

protected string|null $database = null

$endpoint

The ArangoDB database endpoint.

protected string|null $endpoint = null

$password

The ArangoDB database password.

protected string|null $password = null

$username

The ArangoDB database username.

protected string|null $username = null

Methods

assertDatabase()

Assert the database reference.

public assertDatabase(string|null $database) : void
Parameters
$database : string|null
Tags
throws
UnexpectedValueException

assertEndpoint()

Assert the passed-in endpoint reference.

public assertEndpoint(string|null $endpoint) : void
Parameters
$endpoint : string|null
Tags
throws
UnexpectedValueException

assertPassword()

Assert the passed-in password reference.

public assertPassword(string|null $password) : void
Parameters
$password : string|null
Tags
throws
UnexpectedValueException

assertUsername()

Assert the passed-in username reference.

public assertUsername(string|null $username) : void
Parameters
$username : string|null
Tags
throws
UnexpectedValueException

getDatabase()

Returns the database name and asserts the existence of the value.

public getDatabase() : string
Tags
throws
UnexpectedValueException
Return values
string

getEndpoint()

Returns the database endpoint and throws an error if not set.

public getEndpoint() : string
Tags
throws
UnexpectedValueException
Return values
string

getPassword()

Returns the database password and throws an error if not set.

public getPassword() : string
Tags
throws
UnexpectedValueException
Return values
string

getUsername()

Returns the database username and throws an error if not set.

public getUsername() : string
Tags
throws
UnexpectedValueException
Return values
string

initializeArangoDB()

Initialize the arangodb components.

public initializeArangoDB([array<string|int, mixed> $init = [] ]) : static
Parameters
$init : array<string|int, mixed> = []
Return values
static

buildDatabase()

Builds a best-effort {@see Database} HTTP client from the resolved connection settings, or null when no usable endpoint/database is available or the client cannot be constructed.

protected buildDatabase(string $endpoint, string $username, string $password, string $database) : Database|null

No network I/O happens here — the connection is only exercised when a request method (e.g. Database::collections()) is later called by the caller.

Parameters
$endpoint : string

The ArangoDB endpoint (e.g. tcp://127.0.0.1:8529).

$username : string

The connection user.

$password : string

The connection password.

$database : string

The target database name.

Return values
Database|null

resolveDatabase()

Builds the best-effort {@see Database} HTTP client of an action run: every connection setting reads its CLI option first (`--database` / `--endpoint` / `--user` / `--password`) and falls back on the command configuration ({@see ArangoConfigTrait}).

protected resolveDatabase(InputInterface $input) : Database|null

One-stop shop for the actions — see buildDatabase() for the null-on-failure semantics.

Parameters
$input : InputInterface

The action input carrying the optional CLI overrides.

Return values
Database|null

resolveFacade()

Builds the best-effort high-level {@see ArangoDB} façade of an action run, from the same resolved connection settings as {@see resolveDatabase()} — the migration engine hands this façade to every {@see \oihana\arango\migrations\Migration}. Null when no usable endpoint is configured or the façade cannot be constructed.

protected resolveFacade(InputInterface $input) : ArangoDB|null
Parameters
$input : InputInterface

The action input carrying the optional CLI overrides.

Return values
ArangoDB|null
On this page

Search results