1. Go to this page and download the library: Download eos/arango-db-3-connector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eos / arango-db-3-connector example snippets
$arangoDB = \Eos\ArangoDBConnector\ArangoDB::create(
['tcp://127.0.0.1:8529'],
'your_database_name',
'your_database_user',
'your_database_password',
[
\ArangoDBClient\ConnectionOptions::OPTION_WAIT_SYNC => 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([...]);
$connectionFactory = new \Eos\ArangoDBConnector\Connection\ConnectionFactory(
['tcp://127.0.0.1:8529'],
'your_database_name',
'your_database_user',
'your_database_password',
[
\ArangoDBClient\ConnectionOptions::OPTION_WAIT_SYNC => true, // your connection configuration
]
);
/** @var \Eos\ArangoDBConnector\Connection\ConnectionFactoryInterface $connectionFactory */
/** @var \Eos\ArangoDBConnector\Database\DatabaseHandlerInterface $databaseHandler */
$databaseHandler = new \Eos\ArangoDBConnector\Database\DatabaseHandler($connectionFactory);
// create your database (configured in the connection)
$databaseHandler->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');
/** @var \Eos\ArangoDBConnector\Connection\ConnectionFactoryInterface $connectionFactory */
/** @var \Eos\ArangoDBConnector\Collection\CollectionHandlerInterface $collectionHandler */
$collectionHandler = new \Eos\ArangoDBConnector\Collection\CollectionHandler($connectionFactory);
// create a document collection
$collectionHandler->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');