PHPackages                             lvieira/arangodb-php-odm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. lvieira/arangodb-php-odm

ActiveLibrary[Database &amp; ORM](/categories/database)

lvieira/arangodb-php-odm
========================

ArangoDB PHP ODM

v3.12.1(7mo ago)2133[2 PRs](https://github.com/lucassouzavieira/arangodb-php-odm/pulls)MITPHPPHP &gt;=8.2CI failing

Since Oct 22Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/lucassouzavieira/arangodb-php-odm)[ Packagist](https://packagist.org/packages/lvieira/arangodb-php-odm)[ Docs](https://github.com/lucassouzavieira/arangodb-php-odm)[ RSS](/packages/lvieira-arangodb-php-odm/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (21)Used By (0)

[![Codacy Badge](https://camo.githubusercontent.com/d12b5a05f1cb26580bb8b2826510c21f87db5effdeeb264523f82a8ffb425508/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3437353331303161323938393433303438383439666434376339343537303464)](https://www.codacy.com/manual/lucassouzavieira/arangodb-php-odm?utm_source=github.com&utm_medium=referral&utm_content=lucassouzavieira/arangodb-php-odm&utm_campaign=Badge_Grade)[![PHP](https://github.com/lucassouzavieira/arangodb-php-odm/actions/workflows/php.yml/badge.svg)](https://github.com/lucassouzavieira/arangodb-php-odm/actions/workflows/php.yml)

ArangoDB PHP ODM
================

[](#arangodb-php-odm)

[![ArangoDB](https://camo.githubusercontent.com/d04662f6fda500e4285a9ed4fbb6dee77010a4465d136994d0ec1ccbde0380ed/68747470733a2f2f7777772e6172616e676f64622e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30352f4172616e676f44425f6c6f676f5f40322e706e67)](https://camo.githubusercontent.com/d04662f6fda500e4285a9ed4fbb6dee77010a4465d136994d0ec1ccbde0380ed/68747470733a2f2f7777772e6172616e676f64622e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30352f4172616e676f44425f6c6f676f5f40322e706e67)

A new PHP driver for ArangoDB
-----------------------------

[](#a-new-php-driver-for-arangodb)

Installation
------------

[](#installation)

### Using composer

[](#using-composer)

- Run the command below on your project root.
    `composer require lvieira/arangodb-php-odm`

Usage
-----

[](#usage)

### Setting up a new connection

[](#setting-up-a-new-connection)

```
use ArangoDB\Connection\Connection;

// Set a new Connection
$connection = new Connection([
    'endpoint' => 'http://yourarangohost:8529',
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
]);

// Alternatively, you can set a host and a port to connect
$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
]);

// Or set more custom options like 'connection' type and timeout
$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
    'connection' => 'Keep-Alive',
    'timeout' => 30
]);
```

### Managing databases

[](#managing-databases)

With connection, you already set a database. You can get the database instance.

```
use ArangoDB\Database\Database;
use ArangoDB\Collection\Collection;
use ArangoDB\Connection\Connection;

// Set up a connection
$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
]);

$database = $connection->getDatabase();

// With a database object, we can retrieve information about it.
$infoAboutCurrentDatabase = $database->getInfo();

// Check if the database has a collection
if($database->hasCollection('my_collection_name')){
    echo "Collection exists!";
} else {
    echo "Collection doesn't exist";
}

// We can also create collections in the database
$collection = $database->createCollection('my_new_colletion');

// Or retrieve existing collections
$collection = $database->getCollection('my_existing_collection');

// With the Database class we can create and drop databases

// Lists the databases on the server
$dbList = Database::list($connection);

// You can create a new database using the existing connection
$result = Database::create($connection, 'my_database_name');

// And drop databases
$result = Database::drop($connection, 'db_to_drop');
```

### Collections

[](#collections)

You can also work with collections objects directly.

```
use ArangoDB\Collection\Collection;
use ArangoDB\Connection\Connection;

$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
    'connection' => 'Keep-Alive',
    'timeout' => 30
]);

$database = $connection->getDatabase();

// If a collection exists on a database, the object will represent it.
$collection = new Collection('my_collection_name', $database);

// If the collection does not exist, you can create it with the method 'save'
$collection->save();

// Get all documents from the collection
foreach ($collection->all() as $document){
    // Do something.
}
```

### Documents

[](#documents)

```
use ArangoDB\Document\Document;
use ArangoDB\Connection\Connection;

// Set up a connection
$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
]);

// Check if the database has a collection called 'awesome_bands'. If not, create it.
$db = $connection->getDatabase();
if (!$db->hasCollection('awesome_bands')) {
    $db->createCollection('awesome_bands');
}

// Get the collection object
$collection = $db->getCollection('awesome_bands');

$documentAttributes = [
    'band' => 'Quiet Riot',
    'members' => [
        'Kevin DuBrow',
        'Rudy Sarzo',
        'Carlos Cavazo',
        'Frankie Banali'
    ],
    'active_since' => 1975,
    'city' => 'Los Angeles',
    'country' => 'USA'
];

// Create the document object
$document = new Document($documentAttributes, $collection);

// Save the document on collection.
$document->save();

// Add or change document attributes to update the document
$document->status = 'active';
$document->save(); // Will update your document on server;

// Delete the document from the collection.
$document->delete();
```

### Transactions

[](#transactions)

You can perform transactions on ArangoDB Server sending JavaScript code.

```
use ArangoDB\Exceptions\TransactionException;
use ArangoDB\Transaction\JavascriptTransaction;

// Define collections to perform write and read operations.
$options = [
    'collections' => [
        'read' => [
            'fighter_jets'
        ],
        'write' => [
            'fighter_jets'
        ]
    ]
];

// Your JS action to execute.
$action = "function(){ var db = require('@arangodb').db; db.fighter_jets.save({});  return db.fighter_jets.count(); }";

try {
    $transaction = new JavascriptTransaction($this->getConnectionObject(), $action, $options);
    $result = $transaction->execute(); // Will return 1.
} catch (TransactionException $transactionException) {
    // Throws a TransactionException in case of error.
    return $transactionException->getMessage();
}
```

You can also perform transactions directly from PHP.

```
use ArangoDB\Document\Document;
use ArangoDB\Connection\Connection;
use ArangoDB\Transaction\StreamTransaction as Transaction;

$connection = new Connection([
    'host' => 'http://yourarangohost',
    'port' => 8529,
    'username' => 'YourUserName',
    'password' => 'YourSecretPasswd',
    'database' => 'YourDatabase',
]);

$db = $connection->getDatabase();
if (!$db->hasCollection('fighter_jets')) {
    $db->createCollection('fighter_jets');
}

// Define collections to perform write and read operations.
$options = [
    'collections' => [
        'write' => [
            'fighter_jets'
        ]
    ]
];

// Declare a new transaction.
$transaction = new Transaction($connection, $options);

try {
    // Start transaction.
    $transaction->begin();

    // Do something
    $collection = $db->getCollection('fighter_jets');
    $viper = new Document(['model' => 'F-16 Viper', 'status' => 'In service', 'origin' => 'USA'], $collection);
    $gripen = new Document(['model' => 'JAS 39 Gripen', 'status' => 'In service', 'origin' => 'Sweden'], $collection);

    $viper->save();
    $gripen->save();

    // Commit the operations.
    $transaction->commit();
} catch (\Exception $exception) {
    // Some error occurred. Abort transaction.
    $transaction->abort();
}
```

Documentation
-------------

[](#documentation)

Check the [API Reference](https://lucassouzavieira.github.io/arangodb-php-odm/).

Contributing
------------

[](#contributing)

[Check how to contribute to this project](CONTRIBUTING.md)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance73

Regular maintenance activity

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~145 days

Recently: every ~373 days

Total

16

Last Release

220d ago

Major Versions

v0.6.0-alpha → v1.0.02019-12-18

v1.1.2 → v2.0.02021-06-20

v1.2.0 → v3.11.02024-05-15

PHP version history (4 changes)v0.1.7-alphaPHP &gt;=7.1.0

v0.6.0-alphaPHP &gt;=7.2.0

v1.1.2PHP &gt;=7.3.0

v3.11.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/eab8aa7c657f88ca4f8ebe49e29abc45cdf28892f3bd10324bf487f995a27920?d=identicon)[lucassouzavieira](/maintainers/lucassouzavieira)

---

Top Contributors

[![lucassouzavieira](https://avatars.githubusercontent.com/u/13005840?v=4)](https://github.com/lucassouzavieira "lucassouzavieira (341 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

arangodbarangodb-clientnosqlnosql-databasephpphp-librarydatabasenosqlodmgraphsArangoDb

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lvieira-arangodb-php-odm/health.svg)

```
[![Health](https://phpackages.com/badges/lvieira-arangodb-php-odm/health.svg)](https://phpackages.com/packages/lvieira-arangodb-php-odm)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
