An open API service indexing awesome lists of open source software.

https://github.com/eosnewmedia/arangodb-3-connector

Factory and interface wrappers for simpler and cleaner usage of triagens/arangodb
https://github.com/eosnewmedia/arangodb-3-connector

arangodb arangodb-client php php7

Last synced: 23 days ago
JSON representation

Factory and interface wrappers for simpler and cleaner usage of triagens/arangodb

Awesome Lists containing this project

README

        

eos/arango-db-3-connector
=========================
Factory and interface wrappers for simpler and cleaner usage of `triagens/arangodb`.

## Installation

```bash
composer req eos/arango-db-3-connector
```

## Usage

The simplest way to use this library is to create an instance of `ArangoDB` which implements `ArangoDBInterface`.

```php
true, // your connection configuration
]
);

// create your database
$arangoDB->database()->createDatabase();

// create your first collection
$arangoDB->collections()->createDocumentCollection('example');

// create your first document
$arangoDB->execute('INSERT { name: @name } INTO example', ['name'=>'Test']);

// for custom statements use: $arangoDB->statements()->createStatement([...]);

```

### Connections
Connections will be created by an instance of `ConnectionFactoryInterface` if their are needed.

The default implementation of `ConnectionFactoryInterface` is `ConnectionFactory`:

```php
true, // your connection configuration
]
);

```

### Database Management
Your database could be managed with an instance of `DatabaseHandlerInterface`.

The default implementation of `DatabaseHandlerInterface` is `DatabaseHandler`:

```php
createDatabase();

// if your database user is not allowed to create a new database, overwrite the configured user for this action:
$databaseHandler->createDatabase('admin_user','admin_password');

// remove your database (configured in the connection)
$databaseHandler->removeDatabase();

// if your database user is not allowed to remove a database, overwrite the configured user for this action:
$databaseHandler->removeDatabase('admin_user','admin_password');

```

### Collection Management
Your collections could be managed with an instance of `CollectionHandlerInterface`.

The default implementation of `CollectionHandlerInterface` is `CollectionHandler`:

```php
createDocumentCollection('your_collection');

// create an edge collection
$collectionHandler->createEdgeCollection('your_collection');

// create an index for a collection
$collectionHandler->createIndex('your_collection','hash',['your_field']);

// remove a collection
$collectionHandler->removeCollection('your_collection');

```

### Statements
Your statements could be created by an instance of `StatementFactoryInterface`.

The default implementation of `StatementFactoryInterface` is `StatementFactory`:

```php
createStatement(['query'=>'FOR document IN your_collection RETURN document']);
$cursor = $statement->execute();

// create query statement
$statement =$statementFactory->createQueryStatement('INSERT { name: @name } INTO your_collection', ['name'=>'Test']);
$statement->execute();

```