doctrine/orientdb-odm
Doctrine OrientDB ODM integrates OrientDB with Doctrine, offering an object document mapper for PHP. Map documents to classes, manage persistence and queries via a familiar Doctrine-style API, and work with graph/document features using a structured domain model.
doctrine/orientdb-odm package enables integration with OrientDB, a multi-model NoSQL database (graph, document, key-value) within a PHP/Laravel ecosystem. This is ideal for projects requiring:
jenssegers/laravel-mongodb for MongoDB) might suffice for simpler needs. Trade-off: OrientDB’s multi-model capabilities justify adoption only if the project’s data complexity demands it.findOneBy() with path queries).OrientDBManager) to manage connections.Model::saved).composer.json for exact versions).doctrine/dbal).TRAVERSE vs. SQL JOIN).config/database.php:
'orientdb' => [
'driver' => 'orientdb',
'url' => env('ORIENTDB_URL', 'local:2424'),
'username' => env('ORIENTDB_USER'),
'password' => env('ORIENTDB_PASSWORD'),
],
// app/Providers/OrientDBServiceProvider.php
public function register()
{
$config = new \Doctrine\ODM\OrientDB\Configuration();
$config->setProxyDir(sys_get_temp_dir());
$config->setProxyNamespace('App\\OrientDB\\Proxy');
$config->setHydrationCacheSize(128);
$config->setHydrationCacheDriver('array'); // Or Redis
$connection = \Doctrine\ODM\OrientDB\Connection::create(
env('ORIENTDB_URL'),
env('ORIENTDB_USER'),
env('ORIENTDB_PASSWORD')
);
$this->app->singleton('orientdb.odm', function () use ($config, $connection) {
return \Doctrine\ODM\OrientDB\DocumentManager::create($connection, $config);
});
}
// app/OrientDB/User.php
use Doctrine\ODM\OrientDB\Mapping\Annotations as ODM;
/** @ODM\Document */
class User
{
/** @ODM\Id */
private $id;
/** @ODM\Field(type="string") */
private $name;
/** @ODM\EmbedMany(targetDocument="Profile") */
private $profiles;
/** @ODM\ReferenceOne(targetDocument="Post") */
private $latestPost;
}
// app/Repositories/OrientDB/UserRepository.php
class UserRepository
{
public function __construct(private DocumentManager $dm) {}
public function findWithPosts(int $id): ?User
{
return $this->dm->createQueryBuilder(User::class)
->field('id')->equals($id)
->fetchOne();
}
}
// app/Extensions/OrientDBQueryBuilder.php
class OrientDBQueryBuilder extends Builder
{
public function traverse(string $path, int $depth = 1)
{
// Custom logic to append TRAVERSE clauses
}
}
onFlush) to Laravel’s Model::saved via listeners.doctrine/dbal may clash with ODM’s dependencies.replace or conflict directives.CREATE INDEX on traversed properties).How can I help you explore Laravel packages today?