PHPackages                             idct/sonata-admin-mongodb-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. idct/sonata-admin-mongodb-bundle

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

idct/sonata-admin-mongodb-bundle
================================

Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle

v5.2.0(2w ago)0113↑200%[2 PRs](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/pulls)MITPHPPHP ^8.4CI passing

Since May 15Pushed yesterdayCompare

[ Source](https://github.com/ideaconnect/sonata-admin-mongodb-bundle)[ Packagist](https://packagist.org/packages/idct/sonata-admin-mongodb-bundle)[ Docs](https://github.com/ideaconnect/sonata-admin-mongodb-bundle)[ GitHub Sponsors](https://github.com/OskarStark)[ GitHub Sponsors](https://github.com/VincentLanglet)[ RSS](/packages/idct-sonata-admin-mongodb-bundle/feed)WikiDiscussions 5.x Synced 1w ago

READMEChangelogDependencies (34)Versions (5)Used By (0)

idct/sonata-admin-mongodb-bundle
================================

[](#idctsonata-admin-mongodb-bundle)

Doctrine MongoDB ODM persistence backend for **Sonata Admin** — full CRUD, filtering, sorting, pagination, exports and ACL management for MongoDB documents, the same way `sonata-project/doctrine-orm-admin-bundle` provides it for relational databases.

[![Latest Stable Version](https://camo.githubusercontent.com/59ef9c17b53e612de2767818c009493e7cbe7e944b25f087284484ef3d851e30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696463742f736f6e6174612d61646d696e2d6d6f6e676f64622d62756e646c652e7376673f6c6162656c3d737461626c65)](https://packagist.org/packages/idct/sonata-admin-mongodb-bundle)[![License](https://camo.githubusercontent.com/7bc4d383c1eb66aa06f0f5cc8b8a0d3e817c5b509352c12b7cb5aa5b043d79b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696463742f736f6e6174612d61646d696e2d6d6f6e676f64622d62756e646c652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/4d843e5dfe8d7446c0700efa4d6e24b7d1a8a34fbf43b15f088fab78af387e18/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e34253230253743253230382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/supported-versions.php)[![Symfony](https://camo.githubusercontent.com/225f846a0f5cb15151d7b3c5dfb6a21d94ea67ebb69b49df8396eb829489d6d0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d372e34253230253743253230382e302d3030303030303f6c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)](https://symfony.com/releases)[![Doctrine MongoDB ODM](https://camo.githubusercontent.com/7d820583cd1c482362e4e74932a036e7028a64a309a423a1bdb86a8c29c4295c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f637472696e652532304d6f6e676f44422532304f444d2d253545322e362d6f72616e6765)](https://www.doctrine-project.org/projects/mongodb-odm.html)[![Sonata Admin](https://camo.githubusercontent.com/de5fd7ce68fc40994bf57d40a18f785096bf957d17b61ef40938fab13e070c20/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536f6e61746125323041646d696e2d253545342e33392d626c7565)](https://docs.sonata-project.org/projects/admin-bundle)

[![codecov](https://camo.githubusercontent.com/a37993e42a309df7f02769fc84627222e2c5a46e6321f9086cf3cc552d64e466/68747470733a2f2f636f6465636f762e696f2f67682f69646561636f6e6e6563742f736f6e6174612d61646d696e2d6d6f6e676f64622d62756e646c652f6272616e63682f352e782f67726170682f62616467652e7376673f746f6b656e3d79556459326942314156)](https://codecov.io/gh/ideaconnect/sonata-admin-mongodb-bundle)[![Test](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/test.yaml/badge.svg)](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/test.yaml)[![Quality assurance](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/qa.yaml/badge.svg)](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/qa.yaml)[![Lint](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/lint.yaml/badge.svg)](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/lint.yaml)[![Symfony Lint](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/symfony-lint.yaml/badge.svg)](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/symfony-lint.yaml)[![Documentation](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/documentation.yaml/badge.svg)](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/actions/workflows/documentation.yaml)

---

🚨 This is a HARD FORK
---------------------

[](#-this-is-a-hard-fork)

`idct/sonata-admin-mongodb-bundle` is a **hard fork** of [`sonata-project/doctrine-mongodb-admin-bundle`](https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle), not a soft fork or a temporary patch:

- The vendor name and Composer package id are different (`idct/...` vs. `sonata-project/...`) — the two **cannot** be installed side by side and `composer replace` is **not** declared.
- The `5.x` line already breaks BC in places upstream has not: `ModelManager::getDocumentManager()` is private, `ProxyQuery::__call()`is gone, `ProxyQuery::setOptions()` is removed, `ModelFilter::fixIdentifier()`rejects malformed input, `Pager::countResults()` throws when uninitialized, and more. See [UPGRADE-5.0.md](UPGRADE-5.0.md) for the full break list.
- Future releases **will keep diverging** — extending the public API, replacing parts that aren't worth keeping, dropping things upstream still ships. Upstream changes are pulled in selectively, not merged.
- We do **not** sync release numbers with upstream. Our `5.0.0` is the fork's first release; the upstream lineage we forked from is 4.12.0.

**If you need exact upstream behaviour**, stay on `sonata-project/doctrine-mongodb-admin-bundle`. **If you want a modernised base on PHP 8.4+ / Symfony 7.4+ and don't mind moving with us**, this is the right place.

The MIT license, Thomas Rabaix's original copyright, and every upstream contributor's attribution are preserved — see [LICENSE](LICENSE) and the 74-entry author roster in [composer.json](composer.json).

---

What this bundle does
---------------------

[](#what-this-bundle-does)

Installs next to `sonata-project/admin-bundle` and provides every persistence-layer concern Sonata Admin needs in order to drive an admin UI against a MongoDB collection:

- **CRUD** — `ModelManager` implements every CRUD path Sonata calls (`create`, `update`, `delete`, `find`, `findBy`, `findOneBy`, `batchDelete`, `reverseTransform`).
- **Datagrids** — `Pager` + `ProxyQuery` wrap the ODM `QueryBuilder` to give Sonata's listing screens pagination, sorting and a count query routed through `Collection::countDocuments`.
- **Filtering** — twelve ready-to-use filter classes you can declare on an admin: `String`, `Number`, `Boolean`, `Choice`, `Date`, `DateRange`, `DateTime`, `DateTimeRange`, `Id`, `Model` (relations), `Callback` (escape hatch), `Empty` (null / missing field). String filter understands `EQUAL`, `NOT_EQUAL`, `CONTAINS`, `NOT_CONTAINS`, `STARTS_WITH`, `ENDS_WITH` with an optional `case_sensitive` switch and full regex-input escaping.
- **Type guessing** — two `TypeGuesser`s map ODM mapping types (`Type::STRING`, `Type::INT`, `Type::DATE`, …) to Sonata column types and filter types automatically.
- **Builders** — `DatagridBuilder`, `ListBuilder`, `ShowBuilder` and `FormContractor` materialise admin screens from `FieldDescription`s.
- **Exports** — `DataSource` produces a streaming `\Iterator` for Sonata's exporter; pass `hydrate: false` for raw-array CSV/XML/JSON exports bypassing ODM hydration on wide collections.
- **ACLs** — `ObjectAclManipulator` bulk-applies Symfony Security ACE entries to every document of an admin class, batched at 20 docs per flush with progress output.
- **Dotted paths** — `FieldDescriptionFactory` resolves nested paths (`author.publisher.name`) against ODM `ClassMetadata` and surfaces clear errors when a segment isn't actually an association.

If Sonata Admin can do it for SQL via the ORM bundle, this bundle is the piece that lets you do the same for MongoDB.

---

Requirements
------------

[](#requirements)

FloorTested up toPHP8.48.5Symfony7.48.0Sonata Admin Bundle4.39latest 4.xDoctrine MongoDB ODM2.6latest 2.xDoctrine MongoDB ODM Bundle5.0latest 5.xDoctrine Persistence4.0latest 4.xMongoDB server4.0+7.xBoth [PHP 8.4](https://www.php.net/releases/8.4/en.php) and [PHP 8.5](https://www.php.net/releases/8.5/en.php) are supported and exercised in CI. Symfony 7.4 (the current LTS) and 8.0 are the only supported Symfony lines.

---

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

[](#installation)

### Prerequisites

[](#prerequisites)

You should already have a Symfony 7.4+ application with **Sonata Admin Bundle** and **Doctrine MongoDB ODM Bundle** installed — this bundle is the glue between them, not a replacement for either.

```
composer require sonata-project/admin-bundle doctrine/mongodb-odm-bundle
```

### Install

[](#install)

```
composer require idct/sonata-admin-mongodb-bundle
```

Symfony Flex registers the bundle automatically. If you're not using Flex, add it to `config/bundles.php` manually:

```
return [
    // ...
    Sonata\DoctrineMongoDBAdminBundle\SonataDoctrineMongoDBAdminBundle::class => ['all' => true],
];
```

### Declare an admin

[](#declare-an-admin)

Tag any Sonata Admin service with `manager_type: doctrine_mongodb` and Sonata will resolve it through this bundle's implementations:

```
// config/services.php (Symfony 7+ PHP config)
$services->set(App\Admin\BookAdmin::class)
    ->tag('sonata.admin', [
        'manager_type' => 'doctrine_mongodb',
        'model_class'  => App\Document\Book::class,
        'label'        => 'Book',
    ]);
```

### Optional bundle config

[](#optional-bundle-config)

The bundle ships sane defaults; the only config tree it owns is per-type template overrides for list and show columns:

```
# config/packages/sonata_doctrine_mongo_db_admin.yaml
sonata_doctrine_mongo_db_admin:
    templates:
        types:
            list:
                custom_type: '@App/admin/list_custom.html.twig'
            show:
                custom_type: '@App/admin/show_custom.html.twig'
```

---

Testing
-------

[](#testing)

The test suite has three layers:

1. **Pure unit tests** — fast, no external services. Mock Sonata interfaces and exercise our classes in isolation. Most of `tests/Builder/`, `tests/Filter/`, `tests/FieldDescription/`.
2. **Component tests** — build an in-memory `DocumentManager` against a real MongoDB server, persist fixtures, exercise full flows. `PagerTest`, `ProxyQueryTest`, `ModelManagerTest`'s integration cases, `ObjectAclManipulatorTest`.
3. **Functional tests** — boot the test kernel (`tests/App/AppKernel.php`) and drive a real Sonata admin in a real browser via Symfony Panther. `tests/Functional/`.

Layers 2 and 3 need a MongoDB server. Layer 3 additionally needs a Firefox WebDriver.

### Quick start (recommended)

[](#quick-start-recommended)

```
docker compose up -d
PANTHER_SELENIUM_HOST=http://127.0.0.1:4444/wd/hub make test
```

[docker-compose.yml](docker-compose.yml) brings up:

- a `mongo:latest` container on port `27017`
- a `selenium/standalone-firefox:latest` Selenium Grid on port `4444`

Selenium also exposes noVNC at `http://127.0.0.1:7900` (password `secret`) if you want to watch the browser drive the suite.

### Running individual layers

[](#running-individual-layers)

```
make test                            # full suite (needs MongoDB + Firefox)
vendor/bin/phpunit tests/Builder     # unit tests only
vendor/bin/phpunit tests/Functional  # functional tests only
make coverage                        # produces build/logs/clover.xml
```

### Local without docker

[](#local-without-docker)

If you already have MongoDB and a non-snap Firefox + `geckodriver` on your `PATH`, leave `PANTHER_SELENIUM_HOST` unset:

```
make test
```

Panther will start its own Firefox process. This is the path GitHub Actions uses — see [`.github/workflows/test.yaml`](.github/workflows/test.yaml).

### Quality gates

[](#quality-gates)

The CI workflow runs four gates; matching commands run locally as:

```
make test                                                # PHPUnit
vendor/bin/phpstan --no-progress --memory-limit=1G analyse
vendor/bin/rector --no-progress-bar --dry-run
make lint-php                                            # PHP-CS-Fixer
```

All four must be green before a change can land — see [AGENTS.md §7](AGENTS.md) for the definition of done.

---

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

[](#documentation)

For the public API and configuration shape, upstream Sonata's documentation applies as-is: [docs.sonata-project.org/projects/SonataDoctrineMongoDBAdminBundle](https://docs.sonata-project.org/projects/SonataDoctrineMongoDBAdminBundle).

Fork-specific material:

- [AGENTS.md](AGENTS.md) — architectural overview, where each piece lives, how it fits next to Sonata Admin, contribution rules.
- [UPGRADE-5.0.md](UPGRADE-5.0.md) — 4.x → 5.0 break list (per-class).
- [CHANGELOG.md](CHANGELOG.md) — per-release notes.

---

Support
-------

[](#support)

For bugs or feature ideas in this fork, open an issue on [the fork's repository](https://github.com/ideaconnect/sonata-admin-mongodb-bundle/issues).

For general Sonata Admin questions, the upstream [StackOverflow tag](https://stackoverflow.com/questions/tagged/sonata)remains the best place.

---

License
-------

[](#license)

[MIT](LICENSE). Thomas Rabaix's original copyright and every upstream contributor's attribution are preserved; the full author roster lives in [composer.json](composer.json).

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance98

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

5

Last Release

20d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/168780730?v=4)[IDCT Bartosz Pachołek](/maintainers/ideaconnect)[@ideaconnect](https://github.com/ideaconnect)

---

Top Contributors

[![SonataCI](https://avatars.githubusercontent.com/u/12843093?v=4)](https://github.com/SonataCI "SonataCI (491 commits)")[![franmomu](https://avatars.githubusercontent.com/u/720690?v=4)](https://github.com/franmomu "franmomu (275 commits)")[![dunglas](https://avatars.githubusercontent.com/u/57224?v=4)](https://github.com/dunglas "dunglas (79 commits)")[![VincentLanglet](https://avatars.githubusercontent.com/u/9052536?v=4)](https://github.com/VincentLanglet "VincentLanglet (66 commits)")[![jordisala1991](https://avatars.githubusercontent.com/u/1137485?v=4)](https://github.com/jordisala1991 "jordisala1991 (27 commits)")[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (23 commits)")[![greg0ire](https://avatars.githubusercontent.com/u/657779?v=4)](https://github.com/greg0ire "greg0ire (23 commits)")[![rande](https://avatars.githubusercontent.com/u/14672?v=4)](https://github.com/rande "rande (22 commits)")[![bpacholek](https://avatars.githubusercontent.com/u/3039162?v=4)](https://github.com/bpacholek "bpacholek (22 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (19 commits)")[![EmmanuelVella](https://avatars.githubusercontent.com/u/663607?v=4)](https://github.com/EmmanuelVella "EmmanuelVella (17 commits)")[![dmaicher](https://avatars.githubusercontent.com/u/921145?v=4)](https://github.com/dmaicher "dmaicher (12 commits)")[![core23](https://avatars.githubusercontent.com/u/3440437?v=4)](https://github.com/core23 "core23 (11 commits)")[![rakhnin](https://avatars.githubusercontent.com/u/4926761?v=4)](https://github.com/rakhnin "rakhnin (7 commits)")[![dao](https://avatars.githubusercontent.com/u/45507?v=4)](https://github.com/dao "dao (6 commits)")[![kingcrunch](https://avatars.githubusercontent.com/u/90388?v=4)](https://github.com/kingcrunch "kingcrunch (6 commits)")[![WebDaMa](https://avatars.githubusercontent.com/u/6662359?v=4)](https://github.com/WebDaMa "WebDaMa (5 commits)")[![enleur](https://avatars.githubusercontent.com/u/858989?v=4)](https://github.com/enleur "enleur (5 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (5 commits)")[![phansys](https://avatars.githubusercontent.com/u/1231441?v=4)](https://github.com/phansys "phansys (5 commits)")

---

Tags

generatormongodbbootstrapadminAdmin Generatormongosonata

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/idct-sonata-admin-mongodb-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/idct-sonata-admin-mongodb-bundle/health.svg)](https://phpackages.com/packages/idct-sonata-admin-mongodb-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M370](/packages/easycorp-easyadmin-bundle)[sonata-project/doctrine-mongodb-admin-bundle

Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle

68853.6k3](/packages/sonata-project-doctrine-mongodb-admin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1715.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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