$arangoClient = new ArangoClient($config);
Upon creation, you can alter the default configuration of the client. The following options are available:
- endpoint = 'http://localhost:8529'
- connection = 'Keep-Alive'
- version = 1.1
- host = null
- port = null
- username = null
- password = null
- database = '_system'
- jsonStreamDecoderThreshold = 1 * 1024 * 1024
$config = [
'endpoint' => 'http://localhost:8529',
'username' => 'your-database-username',
'password' => 'your-database-password',
'database'=> 'your-database'
];
$arangoClient = new ArangoClient($config);
JSON response decoding is normally done by the default json_decode method. This method is optimized for speed and can take a large amount of memory; up to ~ 20x of the JSON size.
Therefor we use halaxa/json-machine to stream decode for responses larger than 1MB.
You can alter this cutoff by setting the jsonStreamDecoderThreshold
to a different size in Bytes.
This removed any memory issues at the cost of speed.
In addition to the above mentioned options you can use the following Guzzle 7 specific options:
Some common packages and frameworks work with a host/port combination by default. When no endpoint is provided it is constructed from these two options.
$config = [
'host' => 'http://localhost',
'port' => '8529',
'username' => 'your-database-username',
'password' => 'your-database-password',
'database'=> 'your-database'
];
$arangoClient = new ArangoClient($config);
Send a request to ArangoDB's HTTP REST API. This is mostly for internal use but allows you to use unsupported endpoints.
$arangoClient->request(
'get',
'/_api/version',
[
'query' => [
'details' => $details
]
]
]);
rawRequest(string $method, string $uri, array|HttpRequestOptions $options = []): ResponseInterface|null
Returns the raw response of the request. Note that the request itself is made against the configured endpoint but the databasename is not automatically prepended to the uri as opposed to a regular request.
$arangoClient->rawRequest(
'get',
'/_api/version',
[
'query' => [
'details' => $details
]
]
]);
Get the current configuration.
$arangoClient->getConfig()
Return the username;
$arangoClient->getUser();
Set the database to be used for the upcoming requests
$arangoClient->setDatabase('ArangoClientDB');
Return the database name;
$database = $arangoClient->getDatabase();
Pass chained method to the schema manager.
$arangoClient->schema()->createCollection('users');
Pass chained method to the admin manager.
$arangoClient->admin()->getVersion();
You can update the config by calling the connect method. This replaces the underlying connection and prepares the connection for any requests that follow.
$config = [
'host' => 'http://localhost',
'port' => '8529',
'username' => 'your-other-database-username',
'password' => 'your-other-database-password',
'database'=> 'your-other-database'
];
$arangoClient->connect($config): void
Disconnect from the current keep-alive connection, if any.
$arangoClient->disconnect();