Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 89 additions & 127 deletions CHANGELOG.md

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![ArangoDB-Logo](https://docs.arangodb.com/assets/arangodb_logo_2016_inverted.png)
![ArangoDB-Logo](https://www.arangodb.com/docs/assets/arangodb_logo_2016_inverted.png)

# ArangoDB-PHP - A PHP client for ArangoDB

The official ArangoDB PHP Driver.

3.2: [![Build Status](https://travis-ci.org/arangodb/arangodb-php.png?branch=3.2)](https://travis-ci.org/arangodb/arangodb-php)
Expand All @@ -14,8 +15,13 @@ devel: [![Build Status](https://travis-ci.org/arangodb/arangodb-php.png?branch=d

# More information

* More example code, containing some code to create, delete and rename collections, is provided in the [examples](examples) subdirectory that is provided with the library.
- More example code, containing some code to create, delete and rename
collections, is provided in the [examples](examples) subdirectory that is
provided with the library.

* [PHPDoc documentation](http://arangodb.github.io/arangodb-php/) for the complete library
- [PHPDoc documentation](http://arangodb.github.io/arangodb-php/)
for the complete library

* [Follow us on Twitter](https://twitter.com/arangodbphp) [@arangodbphp](https://twitter.com/arangodbphp) to receive updates on the PHP driver
- [Follow us on Twitter](https://twitter.com/arangodbphp)
[@arangodbphp](https://twitter.com/arangodbphp)
to receive updates on the PHP driver
11 changes: 5 additions & 6 deletions docs/Drivers/PHP/GettingStarted/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ArangoDB-PHP - Getting Started

## Description

This PHP client allows REST-based access to documents on the server.
Expand All @@ -13,11 +14,11 @@ The autoloader will care about loading additionally required classes on the fly.

The ArangoDB PHP client is an API that allows you to send and retrieve documents from ArangoDB from out of your PHP application. The client library itself is written in PHP and has no further dependencies but just plain PHP 5.6 (or higher).

The client library provides document and collection classes you can use to work with documents and collections in an OO fashion. When exchanging document data with the server, the library internally will use the [HTTP REST interface of ArangoDB](../../../HTTP/index.html). The library user does not have to care about this fact as all the details of the REST interface are abstracted by the client library.
The client library provides document and collection classes you can use to work with documents and collections in an OO fashion. When exchanging document data with the server, the library internally will use the [HTTP REST interface of ArangoDB](https://www.arangodb.com/docs/stable/http/index.html). The library user does not have to care about this fact as all the details of the REST interface are abstracted by the client library.

## Requirements

* PHP version 5.6 or higher (Travis-tested with PHP 5.6, 7.0, 7.1 and hhvm)
- PHP version 5.6 or higher (Travis-tested with PHP 5.6, 7.0, 7.1 and hhvm)

Note on PHP version support:

Expand All @@ -33,8 +34,7 @@ The ArangoDB-PHP driver version has to match with the ArangoDB version:
- ArangoDB-PHP 3.2.x is on par with the functionality of ArangoDB 3.2.x
- ArangoDB-PHP 3.3.x is on par with the functionality of ArangoDB 3.3.x

etc...

etc.

### Installing the PHP client

Expand All @@ -50,21 +50,20 @@ There are two alternative ways to get the ArangoDB PHP client:
```
composer require triagens/arangodb
```

#### Alternative 2: Cloning the git repository

When preferring this alternative, you need to have a git client installed. To clone the ArangoDB PHP client repository from github, execute the following command in your project directory:

git clone "https://github.com/arangodb/arangodb-php.git"


This will create a subdirectory arangodb-php in your current directory. It contains all the files of the client library. It also includes a dedicated autoloader that you can use for autoloading the client libraries class files.
To invoke this autoloader, add the following line to your PHP files that will use the library:

```php
require 'arangodb-php/autoload.php';
```


The ArangoDB PHP client's autoloader will only care about its own class files and will not handle any other files. That means it is fully nestable with other autoloaders.

#### Alternative 3: Invoking the autoloader directly
Expand Down
9 changes: 5 additions & 4 deletions docs/Drivers/PHP/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ArangoDB-PHP - A PHP client for ArangoDB

The official ArangoDB PHP Driver.

- [Getting Started](GettingStarted/README.md)
Expand All @@ -7,11 +8,11 @@ The official ArangoDB PHP Driver.

# More information

* Check the ArangoDB PHP client on github.com regularly for new releases and updates: [https://github.com/arangodb/arangodb-php](https://github.com/arangodb/arangodb-php)
- Check the ArangoDB PHP client on github.com regularly for new releases and updates: [https://github.com/arangodb/arangodb-php](https://github.com/arangodb/arangodb-php)

* More example code, containing some code to create, delete and rename collections, is provided in the [examples](https://github.com/arangodb/arangodb-php/tree/devel/examples) subdirectory that is provided with the library.
- More example code, containing some code to create, delete and rename collections, is provided in the [examples](https://github.com/arangodb/arangodb-php/tree/devel/examples) subdirectory that is provided with the library.

* [PHPDoc documentation](http://arangodb.github.io/arangodb-php/) for the complete library
- [PHPDoc documentation](http://arangodb.github.io/arangodb-php/) for the complete library

* [Follow us on Twitter](https://twitter.com/arangodbphp)
- [Follow us on Twitter](https://twitter.com/arangodbphp)
[@arangodbphp](https://twitter.com/arangodbphp) to receive updates on the PHP driver
50 changes: 19 additions & 31 deletions docs/Drivers/PHP/Tutorial/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ArangoDB-PHP - Tutorial

## Setting up the connection options

In order to use ArangoDB, you need to specify the connection options. We do so by creating a PHP array $connectionOptions. Put this code into a file named test.php in your current directory:
Expand Down Expand Up @@ -60,20 +61,19 @@ ArangoException::enableLogging();

This will make the client connect to ArangoDB

* running on localhost (OPTION_HOST)
* on the default port 8529 (OPTION_PORT)
* with a connection timeout of 3 seconds (OPTION_TIMEOUT)
- running on localhost (OPTION_HOST)
- on the default port 8529 (OPTION_PORT)
- with a connection timeout of 3 seconds (OPTION_TIMEOUT)

When creating new documents in a collection that does not yet exist, you have the following choices:

* auto-generate a new collection: if you prefer that, set OPTION_CREATE to true
* fail with an error: if you prefer this behavior, set OPTION_CREATE to false
- auto-generate a new collection: if you prefer that, set OPTION_CREATE to true
- fail with an error: if you prefer this behavior, set OPTION_CREATE to false

When updating a document that was previously/concurrently updated by another user, you can select between the following behaviors:

* last update wins: if you prefer this, set OPTION_UPDATE_POLICY to last
* fail with a conflict error: if you prefer that, set OPTION_UPDATE_POLICY to conflict

- last update wins: if you prefer this, set OPTION_UPDATE_POLICY to last
- fail with a conflict error: if you prefer that, set OPTION_UPDATE_POLICY to conflict

## Setting up active failover

Expand All @@ -95,6 +95,7 @@ $connectionOptions = [
ConnectionOptions::OPTION_ENDPOINT => [ 'tcp://localhost:8531', 'tcp://localhost:8532', 'tcp://localhost:8530' ]
];
```

Using this option requires ArangoDB 3.3 or higher and the database running
in active failover mode.

Expand Down Expand Up @@ -132,8 +133,8 @@ $connectionOptions = [
];
```


## Creating a collection

*This is just to show how a collection is created.*
*For these examples it is not needed to create a collection prior to inserting a document, as we set ArangoConnectionOptions::OPTION_CREATE to true.*

Expand Down Expand Up @@ -162,8 +163,8 @@ The below code will first set up the collection locally in a variable name $user
// check if the collection exists
$result = $collectionHandler->has('users');
var_dump($result);
```

```
## Creating a document

After we created the collection, we can start with creating an initial document. We will create a user document in a collection named "users". This collection does not need to exist yet. The first document we'll insert in this collection will create the collection on the fly. This is because we have set OPTION_CREATE to true in $connectionOptions.
Expand Down Expand Up @@ -202,30 +203,29 @@ As you can see, sending a document to the server is achieved by calling the save

## Adding exception handling


The above code will work but it does not check for any errors. To make it work in the face of errors, we'll wrap it into some basic exception handlers

```php
try {
$handler = new ArangoDocumentHandler($connection);

// create a new document
$user = new ArangoDocument();

// use set method to set document properties
$user->set('name', 'John');
$user->set('age', 25);

// use magic methods to set document properties
$user->likes = ['fishing', 'hiking', 'swimming'];

// send the document to the server
$id = $handler->save('users', $user);

// check if a document exists
$result = $handler->has('users', $id);
var_dump($result);

// print the document id created by the server
var_dump($id);
var_dump($user->getId());
Expand Down Expand Up @@ -291,7 +291,6 @@ Note that CollectionHandler->byExample() might return multiple documents if the

## Updating a document


To update an existing document, the update() method of the *DocumentHandler* class can be used.
In this example we want to
- set state to 'ca'
Expand Down Expand Up @@ -389,12 +388,10 @@ Note that the document must have been fetched from the server before. If you hav
}
```


## Running an AQL query


To run an AQL query, use the *Statement* class.

The method Statement::execute creates a Cursor object which can be used to iterate over
the query's result set.

Expand Down Expand Up @@ -440,7 +437,6 @@ that cannot be converted into Document objects.
In order to suppress the conversion into Document objects, the Statement must be given
the `_flat` attribute. This allows processing the results of arbitrary AQL queries:


```php
// run an AQL query that does not return documents but scalars
// we need to set the _flat attribute of the Statement in order for this to work
Expand All @@ -460,17 +456,14 @@ the `_flat` attribute. This allows processing the results of arbitrary AQL queri

```


## Exporting data


To export the contents of a collection to PHP, use the *Export* class.
The *Export* class will create a light-weight cursor over all documents
of the specified collection. The results can be transferred to PHP
in chunks incrementally. This is the most efficient way of iterating
over all documents in a collection.


```php
// creates an export object for collection users
$export = new ArangoExport($connection, 'users', []);
Expand Down Expand Up @@ -504,12 +497,10 @@ over all documents in a collection.

## Bulk document handling


The ArangoDB-PHP driver provides a mechanism to easily fetch multiple documents from
the same collection with a single request. All that needs to be provided is an array
of document keys:


```php
$exampleCollection = new ArangoCollection();
$exampleCollection->setName('example');
Expand All @@ -536,11 +527,9 @@ of document keys:
$result = $collectionHandler->removeByKeys('example', $keys);

var_dump($result);


```
## Dropping a collection

## Dropping a collection

To drop an existing collection on the server, use the drop() method of the *CollectionHandler* class.
drop() just needs the name of the collection name to be dropped:
Expand Down Expand Up @@ -576,7 +565,6 @@ See file examples/customDocumentClass.php for more details.

## Logging exceptions


The driver provides a simple logging mechanism that is turned off by default. If it is turned on, the driver
will log all its exceptions using PHP's standard `error_log` mechanism. It will call PHP's `error_log()`
function for this. It depends on the PHP configuration if and where exceptions will be logged. Please consult
Expand Down
4 changes: 2 additions & 2 deletions docs/classes/ArangoDBClient.AdminHandler.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ <h2>Get the server statistics
<table class="table table-bordered">
<tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/AdministrationAndMonitoring/index.html">This will throw if the statistics cannot be retrieved</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html">This will throw if the statistics cannot be retrieved</a></td>
</tr>
<tr>
<th>see</th>
Expand Down Expand Up @@ -283,7 +283,7 @@ <h2>Returns a description of the statistics returned by getServerStatistics().</
<table class="table table-bordered">
<tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/AdministrationAndMonitoring/index.html">This will throw if the statistics-description cannot be retrieved</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html">This will throw if the statistics-description cannot be retrieved</a></td>
</tr>
<tr>
<th>see</th>
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/ArangoDBClient.CollectionHandler.html
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ <h2>Import documents into a collection</h2>
<div class="long_description"><p>This will throw on all errors except insertion errors</p></div>
<table class="table table-bordered"><tr>
<th>see</th>
<td><a href="https://docs.arangodb.com/3.1/HTTP/BulkImports/"></a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/bulk-imports.html"></a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down
14 changes: 7 additions & 7 deletions docs/classes/ArangoDBClient.Database.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<table class="table table-bordered">
<tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr>
<tr>
<th>package</th>
Expand All @@ -116,7 +116,7 @@ <h2>creates a database</h2>
<div class="long_description"><p>This creates a new database<br></p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down Expand Up @@ -153,7 +153,7 @@ <h2>List databases</h2>
<div class="long_description"><p>This will list the databases that exist on the server</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down Expand Up @@ -185,7 +185,7 @@ <h2>Deletes a database</h2>
<div class="long_description"><p>This will delete an existing database.</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down Expand Up @@ -222,7 +222,7 @@ <h2>Retrieves information about the current database</h2>
<div class="long_description"><p>This will get information about the currently used database from the server</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down Expand Up @@ -254,7 +254,7 @@ <h2>List databases</h2>
<div class="long_description"><p>This will list the databases that exist on the server</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down Expand Up @@ -287,7 +287,7 @@ <h2>List user databases</h2>
specifying a different username or password.</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Database/index.html">https://docs.arangodb.com/HTTP/Database/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/database.html">https://www.arangodb.com/docs/stable/http/database.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/ArangoDBClient.Endpoint.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ <h2>List endpoints</h2>
<div class="long_description"><p>This will list the endpoints that are configured on the server</p></div>
<table class="table table-bordered"><tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Endpoints/index.html">https://docs.arangodb.com/HTTP/Endpoints/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/endpoints.html">https://www.arangodb.com/docs/stable/http/endpoints.html</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/ArangoDBClient.Traversal.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<table class="table table-bordered">
<tr>
<th>link</th>
<td><a href="https://docs.arangodb.com/HTTP/Traversal/index.html">https://docs.arangodb.com/HTTP/Traversal/index.html</a></td>
<td><a href="https://www.arangodb.com/docs/stable/http/traversal.html">https://www.arangodb.com/docs/stable/http/traversal.html</a></td>
</tr>
<tr>
<th>package</th>
Expand Down
Loading