|
| 1 | +# ArangoDB PHP Client |
| 2 | +``` |
| 3 | +$arangoClient = new ArangoClient($config); |
| 4 | +``` |
| 5 | + |
| 6 | +## Configuration |
| 7 | +Upon creation, you can alter the default configuration of the client. The following options are available: |
| 8 | +* endpoint = 'http://localhost:8529' |
| 9 | +* host = null |
| 10 | +* port = null |
| 11 | +* username = null |
| 12 | +* password = null |
| 13 | +* database = '_system' |
| 14 | +* connection = 'Keep-Alive' |
| 15 | + |
| 16 | +``` |
| 17 | +$config = [ |
| 18 | + 'endpoint' => 'http://localhost:8529', |
| 19 | + 'username' => 'your-database-username', |
| 20 | + 'password' => 'your-database-password', |
| 21 | + 'database'=> 'your-database' |
| 22 | +]; |
| 23 | +
|
| 24 | +$arangoClient = new ArangoClient($config); |
| 25 | +``` |
| 26 | + |
| 27 | +### Support Guzzle configuration |
| 28 | +In addition to the above mentioned options you can use the following Guzzle 7 specific options: |
| 29 | +* allow_redirects |
| 30 | +* connect_timeout |
| 31 | + |
| 32 | +### Endpoint vs host/port |
| 33 | +Some common packages and frameworks work with a host/port combination by default. |
| 34 | +When no endpoint is provided it is constructed from these two options. |
| 35 | + |
| 36 | +``` |
| 37 | +$config = [ |
| 38 | + 'host' => 'http://localhost', |
| 39 | + 'port' => '8529', |
| 40 | + 'username' => 'your-database-username', |
| 41 | + 'password' => 'your-database-password', |
| 42 | + 'database'=> 'your-database' |
| 43 | +]; |
| 44 | +
|
| 45 | +$arangoClient = new ArangoClient($config); |
| 46 | +``` |
| 47 | + |
| 48 | +## Functions |
| 49 | + |
| 50 | +### request(string $method, string $uri, array $options = []): array |
| 51 | +Send a request to ArangoDB's HTTP REST API. This is mostly for internal use but allows you to use unsupported endpoints. |
| 52 | +``` |
| 53 | +$arangoClient->request( |
| 54 | + 'get', |
| 55 | + '/_api/version', |
| 56 | + 'query' => [ |
| 57 | + 'details' => $details |
| 58 | + ] |
| 59 | +]); |
| 60 | +``` |
| 61 | + |
| 62 | +### getConfig(): array |
| 63 | +Get the current configuration. |
| 64 | +``` |
| 65 | +$arangoClient->getConfig() |
| 66 | +``` |
| 67 | + |
| 68 | +### getUser(): string |
| 69 | +Return the username; |
| 70 | +``` |
| 71 | +$arangoClient->getUser(); |
| 72 | +``` |
| 73 | + |
| 74 | +### setDatabase(string $name): void |
| 75 | +Set the database to be used for the upcoming requests |
| 76 | +``` |
| 77 | +$arangoClient->setDatabase('ArangoClientDB'); |
| 78 | +``` |
| 79 | + |
| 80 | +### getDatabase(): string |
| 81 | +Return the database name; |
| 82 | +``` |
| 83 | +$database = $arangoClient->getDatabase(); |
| 84 | +``` |
| 85 | + |
| 86 | +### schema(): SchemaManager |
| 87 | +Pass chained method to the schema manager. |
| 88 | +``` |
| 89 | +$arangoClient->schema()->createCollection('users'); |
| 90 | +``` |
| 91 | + |
| 92 | +### admin(): AdminManager |
| 93 | +Pass chained method to the admin manager. |
| 94 | +``` |
| 95 | +$arangoClient->admin()->getVersion(); |
| 96 | +``` |
0 commit comments