PHPackages                             kairos-project/api-doctrine-mongodb-odm-loader - 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. kairos-project/api-doctrine-mongodb-odm-loader

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

kairos-project/api-doctrine-mongodb-odm-loader
==============================================

The doctrine ODM component of the kairos API. Aim to be used as data access object for mongoDB

06PHP

Since Aug 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kairosProject/ApiDoctrineMongoDBODMLoader)[ Packagist](https://packagist.org/packages/kairos-project/api-doctrine-mongodb-odm-loader)[ RSS](/packages/kairos-project-api-doctrine-mongodb-odm-loader/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

ApiDoctrineMongoDBODMLoader
===========================

[](#apidoctrinemongodbodmloader)

The doctrine ODM component of the kairos API. Aim to be used as data access object for MongoDB

1) Subject
----------

[](#1--subject)

The doctrine MongoDB ODM loader is an implementation of the abstract API loading system. It is in charge of the data access in front of a MongoDB database and uses doctrine MongoDB ODM library.

2) Class architecture
---------------------

[](#2-class-architecture)

The doctrine MongoDB loader is a simple inheritance of the API loader.

3) Dependency description and use into the element
--------------------------------------------------

[](#3-dependency-description-and-use-into-the-element)

A the time of writing, the doctrine MongoDB loader is designed to have four production dependencies as:

- psr/log
- symfony/event-dispatcher
- kairos-project/api-controller
- kairos-project/api-loader

### 3.1) psr/log

[](#31-psrlog)

The debugging and error retracement in each project parts is currently a fundamental law in development and it's missing is part of the OWASP top ten threats.

As defined by the third PHP standard reference, the logger components have to implement a specific interface. By the way, the logging system will be usable by each existing frameworks.

### 3.2) symfony/event-dispatcher

[](#32-symfonyevent-dispatcher)

The loader system is designed to be easily extendable and will implement an event dispatching system, allowing the attachment and separation of logic by priority.

### 3.3) kairos-project/api-controller

[](#33-kairos-projectapi-controller)

The loader is made to be used by APIs and the generic system into kairos project is the API controller. This system offer access to specialized workflow events.

The loader will define the controller component as a dependency to make use of the workflow events.

### 3.4) kairos-project/api-loader

[](#34-kairos-projectapi-loader)

The doctrine MongoDB loader inherits the API loader. It uses the base loader logic and has to define it as a dependency.

4) Implementation specification
-------------------------------

[](#4-implementation-specification)

To inherit the abstract API loader, this component will have to define the abstract methods methods:

- getQueryBuildingEvent
- instanciateQueryBuilder
- executeCollectionQuery
- executeItemQuery
- configureQueryForCollection
- configureQueryForItem

#### 4.1) Dependency injection specification

[](#41-dependency-injection-specification)

The document class has to be known to create a new query builder object. This information has to be introduced by the loader constructor.

The system needs to take the item identifier from the request. Two parameters will be introduced to determine its place, and one more to define the identifier field. So the bag name, the parameter key and the identifier name have to be injected.

A document manager has to be provided at the instantiation to access the connection.

#### 4.2) getQueryBuildingEvent algorithm

[](#42-getquerybuildingevent-algorithm)

The getQueryBuildingEvent method is in charge of the query building event instantiation.

```
We assume to receive the process event from the parameters.

The method instantiates a new QueryBuildingEvent and injects the process event in the constructor.

Finally, the new event is passing back.
```

#### 4.3) instanciateQueryBuilder algorithm

[](#43-instanciatequerybuilder-algorithm)

The instanciateQueryBuilder method will create a new query builder instance to be used by the configuration and execution methods.

```
We assume to receive the query building event from the parameters.

The method instantiates a new query builder from doctrine document manager. The document name stored inside the documentName attribute used as a constructor argument.

The query building event will receive the builder.
```

#### 4.4) configureQueryForItem algorithm

[](#44-configurequeryforitem-algorithm)

The configureQueryForItem method will configure the query builder instance to load a specific element.

```
We assume to receive the query building event from the parameters.
We assume the query builder as query building event part.
We assume the bag name and parameter key as loader attribute.
We assume the identifier field name as loader attribute.

Get the item identifier from the request bag, using the bag name and parameter key.
Define the query field equality clause, regarding the identifier field.
```

#### 4.5) configureQueryForCollection algorithm

[](#45-configurequeryforcollection-algorithm)

The configureQueryForCollection method will configure the query builder instance to load a set of elements. This method will stay empty for the MongoDB state. In matter, the instanciateQueryBuilder method is adequate.

#### 4.6) executeCollectionQuery algorithm

[](#46-executecollectionquery-algorithm)

The executeCollectionQuery method will return the query result.

```
We assume to receive the query building event from the parameters.
We assume the query builder as query building event part.

Execute the query.
Return the query execution result.
```

#### 4.7) executeItemQuery algorithm

[](#47-executeitemquery-algorithm)

The executeItemQuery method will implement the same logic than the executeCollectionQuery but will return a single query result.

5) Usage
--------

[](#5-usage)

#### 5.1) Basic usage

[](#51-basic-usage)

```
use KairosProject\ApiDoctrineMongoDBODMLoader\Loader\Loader;
use Symfony\Component\EventDispatcher\EventDispatcher;

// Instanciating event dispatcher
$eventDispatcher = new EventDispatcher();

$loader = new Loader(
    Document::class,
    'id',
    Loader::attribute,
    'document_id'
    $logger
);

$documentList = $loader->loadCollection($event, 'event_name', $eventDispatcher);

$document = $loader->loadItem($event, 'event_name', $eventDispatcher);
$item = $event->getParameter(Loader::EVENT_KEY_STORAGE);
```

#### 5.2) Complete constructor usage

[](#52-complete-constructor-usage)

```
public function __construct(
        string $documentName,
        string $identifierField,
        string $requestBag,
        string $requestBagKey,
        LoggerInterface $logger,
        string $collectionEventName = self::COLLECTION_EVENT_NAME,
        string $itemEventName = self::ITEM_EVENT_NAME,
        string $eventKeyStorage = self::EVENT_KEY_STORAGE,
        bool $noItemException = self::NO_ITEM_EXCEPTION
);
```

#### 5.3) Loading with extension

[](#53-loading-with-extension)

```
use KairosProject\ApiDoctrineMongoDBODMLoader\Loader\Loader;
use Symfony\Component\EventDispatcher\EventDispatcher;

// Instanciating event dispatcher
$eventDispatcher = new EventDispatcher();

$eventDispatcher->addListener(
    Loader::COLLECTION_EVENT_NAME,
    [
        $extension,
        'someFunction'
    ]
);

$loader = new Loader(
    Document::class,
    'id',
    Loader::attribute,
    'document_id'
    $logger
);

$documentList = $loader->loadCollection($event, 'event_name', $eventDispatcher);
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12436206?v=4)[cscfa](/maintainers/cscfa)[@cscfa](https://github.com/cscfa)

---

Top Contributors

[![matthieu88160](https://avatars.githubusercontent.com/u/11874266?v=4)](https://github.com/matthieu88160 "matthieu88160 (7 commits)")

### Embed Badge

![Health badge](/badges/kairos-project-api-doctrine-mongodb-odm-loader/health.svg)

```
[![Health](https://phpackages.com/badges/kairos-project-api-doctrine-mongodb-odm-loader/health.svg)](https://phpackages.com/packages/kairos-project-api-doctrine-mongodb-odm-loader)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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