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
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
assertEndpoint()
Assert the passed-in endpoint reference.
public
assertEndpoint(string|null $endpoint) : void
Parameters
- $endpoint : string|null
Tags
assertPassword()
Assert the passed-in password reference.
public
assertPassword(string|null $password) : void
Parameters
- $password : string|null
Tags
assertUsername()
Assert the passed-in username reference.
public
assertUsername(string|null $username) : void
Parameters
- $username : string|null
Tags
getDatabase()
Returns the database name and asserts the existence of the value.
public
getDatabase() : string
Tags
Return values
stringgetEndpoint()
Returns the database endpoint and throws an error if not set.
public
getEndpoint() : string
Tags
Return values
stringgetPassword()
Returns the database password and throws an error if not set.
public
getPassword() : string
Tags
Return values
stringgetUsername()
Returns the database username and throws an error if not set.
public
getUsername() : string
Tags
Return values
stringinitializeArangoDB()
Initialize the arangodb components.
public
initializeArangoDB([array<string|int, mixed> $init = [] ]) : static
Parameters
- $init : array<string|int, mixed> = []
Return values
staticbuildDatabase()
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|nullresolveDatabase()
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|nullresolveFacade()
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.