Oihana PHP Arango

ArangoListCollectionsAction uses trait:short, trait:short, \oihana\commands\traits\IOTrait

Lists the collections of the ArangoDB database through the HTTP client.

Unlike the dump/restore actions (which shell out to the arangodump / arangorestore binaries), this action queries the live database via ArangoClientTrait::buildDatabase() and prints the collection names. Three scopes are available:

  • default : user collections only (non-system).
  • --system : system collections only (names starting with _).
  • --all : every collection.
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

PARTIAL_MARKER  : string = 'partial'
Marker appended to the archive name when the dump targets a subset of collections (either `--collection` or `--ignore-collection`).

Methods

assertCollectionTargeting()  : void
Asserts that `--collection` and `--ignore-collection` are not used together — `arangodump` rejects that combination.
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.
collections()  : int
Lists the collections of the database.
excludeCollections()  : array<int, string>
Returns the available collection names minus the excluded ones, order-preserving (case-sensitive).
getArchiveNameSuffix()  : string
Builds the archive name suffix (without file extension) shared by the dump output name and the restore-by-date lookup.
isSystemCollection()  : bool
Returns true when the given name is an ArangoDB system collection (its name starts with an underscore, e.g. `_jobs`, `_apps`).
missingCollections()  : array<int, string>
Returns the requested collection names that are NOT present in the available set (case-sensitive, as ArangoDB collection names are).
normalizeCollections()  : array<int, string>
Normalizes a raw collection option into a clean, de-duplicated, order-preserving list of collection names.
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.
sanitizeLabel()  : string|null
Validates and normalizes the optional archive label.

Constants

PARTIAL_MARKER

Marker appended to the archive name when the dump targets a subset of collections (either `--collection` or `--ignore-collection`).

public string PARTIAL_MARKER = 'partial'

Methods

assertCollectionTargeting()

Asserts that `--collection` and `--ignore-collection` are not used together — `arangodump` rejects that combination.

protected static assertCollectionTargeting(array<int, string> $collection, array<int, string> $ignore) : void
Parameters
$collection : array<int, string>
$ignore : array<int, string>
Tags
throws
InvalidArgumentException

When both lists are non-empty.

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

collections()

Lists the collections of the database.

protected collections(InputInterface $input, OutputInterface $output) : int
Parameters
$input : InputInterface
$output : OutputInterface
Return values
int

excludeCollections()

Returns the available collection names minus the excluded ones, order-preserving (case-sensitive).

protected static excludeCollections(array<int, string> $available, array<int, string> $exclude) : array<int, string>

Used to resolve --ignore-collection client-side: arangodump has no exclusion option, so the complement is computed here and passed back as an explicit --collection list.

Parameters
$available : array<int, string>

The collections that exist.

$exclude : array<int, string>

The collections to drop.

Return values
array<int, string>

getArchiveNameSuffix()

Builds the archive name suffix (without file extension) shared by the dump output name and the restore-by-date lookup.

protected static getArchiveNameSuffix(string $database[, bool $partial = false ][, string|null $label = null ]) : string

Shape: -{database}[-partial][-{label}], e.g.

  • -mydb (full dump)
  • -mydb-partial (targeted dump, no label)
  • -mydb-partial-pre-migration (targeted dump with a label)
Parameters
$database : string

The database name.

$partial : bool = false

Whether the dump targets a subset of collections.

$label : string|null = null

Optional label (validated via sanitizeLabel()).

Tags
throws
InvalidArgumentException

When the label is invalid.

Return values
string

isSystemCollection()

Returns true when the given name is an ArangoDB system collection (its name starts with an underscore, e.g. `_jobs`, `_apps`).

protected static isSystemCollection(string $name) : bool
Parameters
$name : string
Return values
bool

missingCollections()

Returns the requested collection names that are NOT present in the available set (case-sensitive, as ArangoDB collection names are).

protected static missingCollections(array<int, string> $requested, array<int, string> $available) : array<int, string>

Order-preserving and de-duplicated.

Parameters
$requested : array<int, string>

The collections asked for on the CLI.

$available : array<int, string>

The collections that actually exist.

Return values
array<int, string>

The unknown collection names (empty when all exist).

normalizeCollections()

Normalizes a raw collection option into a clean, de-duplicated, order-preserving list of collection names.

protected static normalizeCollections(array<int|string, mixed> $raw) : array<int, string>

Accepts both syntaxes (and any mix):

  • repeated flags : ['users', 'products']
  • comma-separated : ['users,products']
  • mixed/with spaces : [' users , products ', 'customers']

Empty fragments are dropped; the first occurrence order is kept.

Parameters
$raw : array<int|string, mixed>
Return values
array<int, string>

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

sanitizeLabel()

Validates and normalizes the optional archive label.

protected static sanitizeLabel(string|null $label) : string|null

Returns null for a null/empty value. Otherwise the label must only contain letters, digits, dot, underscore and hyphen so it stays safe inside a filename.

Parameters
$label : string|null
Tags
throws
InvalidArgumentException

When the label contains unsafe characters.

Return values
string|null
On this page

Search results