PHPackages                             silpo-tech/odm-bundle - 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. silpo-tech/odm-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

silpo-tech/odm-bundle
=====================

Common ODM bundle

v2.0.0(7mo ago)01.1k↓23.1%MITPHPPHP ^8.1CI passing

Since Oct 1Pushed 7mo agoCompare

[ Source](https://github.com/silpo-tech/OdmBundle)[ Packagist](https://packagist.org/packages/silpo-tech/odm-bundle)[ RSS](/packages/silpo-tech-odm-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (16)Versions (3)Used By (0)

ODM Bundle
==========

[](#odm-bundle)

[![CI](https://github.com/silpo-tech/OdmBundle/actions/workflows/ci.yml/badge.svg)](https://github.com/silpo-tech/OdmBundle/actions)[![codecov](https://camo.githubusercontent.com/4d0ac8396266731f8efae89e6899f6b0b78ef2e0705bb90569857453a346b15c/68747470733a2f2f636f6465636f762e696f2f67682f73696c706f2d746563682f4f646d42756e646c652f67726170682f62616467652e737667)](https://codecov.io/gh/silpo-tech/OdmBundle)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

About
-----

[](#about)

The ODM Bundle contains common used ODM classes (e.g. Validators)

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

[](#installation)

Require the bundle and its dependencies with composer:

```
$ composer require silpo-tech/odm-bundle
```

Register the bundle:

```
// project/config/bundles.php

return [
    ODMBundle\ODMBundle::class => ['all' => true],
];
```

Examples
--------

[](#examples)

### FilterValueResolver

[](#filtervalueresolver)

Add converter annotation to argument for your dto

```
     public function __invoke(#[OdmFilterMapper] ExternalCategoryFilterDto $dto)
```

```
class ExternalCategoryFilterDto
{
    public $externalId;
    public $title;
    public $mappings;

    /**
     * @Assert\Type("array")
     * @Assert\Choice(multiple=true, choices={"title", "-title", "createdAt", "-createdAt"})
     *
     * @var array
     */
    public $sort = ['title'];
}
```

### AbstractBuilderAwareFilter

[](#abstractbuilderawarefilter)

Extend your filter class with AbstractBuilderAwareFilter and implement filtration methods. Sorting implementation is defined in AbstractBuilderAwareFilter and will be called if $dto-&gt;sort is not empty

```
class ExternalCategoryFilter extends AbstractBuilderAwareFilter
{
    protected function aggregationTitle(MatchStage $match, $value): void
    {
        $match->field('title')->equals(new Regex(sprintf('^.*%s.*$', $value), 'i'));
    }

    protected function aggregationExternalId(MatchStage $match, string $value): void
    {
        $match->field('externalId')->equals($value);
    }

    protected function aggregationCreatedAt(MatchStage $match, array $value): void
    {
        $this->aggregationFilterDate($match, $value, 'createdAt', true);
    }

    protected function aggregationMappings(MatchStage $match, bool $value): void
    {
        $field = $match->lookup('mappings')->match()->field('mappings');
        $value ? $field->not($match->expr()->size(0)) : $field->size(0);
    }

    protected function queryTitle(QueryBuilder $qb, $value): void
    {
        $qb->field('title')->equals(new Regex(sprintf('^.*%s.*$', $value), 'i'));
    }

    protected function queryExternalId(QueryBuilder $qb, string $value): void
    {
        $qb->field('externalId')->equals($value);
    }

    protected function queryCreatedAt(QueryBuilder $qb, array $value): void
    {
        $this->queryFilterDate($qb, $value, 'createdAt', true);
    }
}
```

Call filtration from repository

```
        //$qb = $this->createQueryBuilder();
        $qb = $this->createAggregationBuilder()->hydrate(ExternalCategory::class);

        (new ExternalCategoryFilter())->filter($qb, $filterDto);
```

### Paginator

[](#paginator)

```
        //$qb = $this->createQueryBuilder();
        $qb = $this->createAggregationBuilder()->hydrate(ExternalCategory::class);

        return (new BuilderAwarePaginator())->paginate($qb, $paginationDto);
```

```
    public function listAction(OffsetPaginator $paginationDto): Response
    {
        $result = $this->repository->paginate($paginationDto);

        return $this->createPaginatedCollectionResponse(
            $result->total,
            $this->mapper->convertCollection($result->items, ResponseExternalCategoryDto::class),
            $paginationDto
        );
    }
```

### Validator

[](#validator)

```
/**
 * @Assert\GroupSequence({"ExternalCategoryMappingDto", "ODM"})
 * @OdmExists(
 *     documentClass="App\Document\ExternalCategory",
 *     fields={"externalCategoryId":"_id"},
 *     errorPath="externalCategory"
 * )
 * @OdmNotExists(
 *     documentClass="App\Document\ExternalCategoryMapping",
 *     fields={
 *      "categoryId":"categoryId",
 *      "externalCategoryId":"externalCategory",
 *      "externalBrandId":"externalBrand"
 *     },
 *     ignoreNull=false,
 *     errorPath="externalCategoryMapping"
 * )
 *
 */
class ExternalCategoryMappingDto {
    /**
     * @ValidDateRange(format="Y-m-d", allowEqual=true),
     *
     * @var array with keys ['from', 'to']
     */
    public $createdAt;
}
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance63

Regular maintenance activity

Popularity20

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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 ~1 days

Total

2

Last Release

228d ago

Major Versions

v1.0.0 → v2.0.02025-10-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9891deddc63cb60dd472af17aee913a559f29defbe861135037dbbdf99449a6?d=identicon)[food-tech-devs](/maintainers/food-tech-devs)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/silpo-tech-odm-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/silpo-tech-odm-bundle/health.svg)](https://phpackages.com/packages/silpo-tech-odm-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

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

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[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)
