PHPackages                             georgebent/mongodb-migrations-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. georgebent/mongodb-migrations-bundle

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

georgebent/mongodb-migrations-bundle
====================================

Symfony bundle for MongoDB migrations

v1.2.0(2mo ago)010MITPHPPHP ^8.5CI passing

Since Mar 14Pushed 2mo agoCompare

[ Source](https://github.com/georgebent/mongodb-migrations-bundle)[ Packagist](https://packagist.org/packages/georgebent/mongodb-migrations-bundle)[ RSS](/packages/georgebent-mongodb-migrations-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (15)Versions (5)Used By (0)

MongoDB Migrations Bundle
=========================

[](#mongodb-migrations-bundle)

Symfony bundle for MongoDB migrations with explicit layer separation and console-driven workflow.

Install
-------

[](#install)

```
composer require georgebent/mongodb-migrations-bundle
```

Register the bundle manually only if your application does not use Symfony Flex auto-registration.

Environment
-----------

[](#environment)

Add MongoDB connection values to an environment-specific file such as `.env.local`:

```
MONGODB_URL=mongodb://admin:admin@172.20.0.12:27017
MONGODB_DB=api-push-notification
```

Configuration
-------------

[](#configuration)

Create `config/packages/mongodb_migrations.yaml` in your Symfony application:

```
mongodb_migrations:
    url: '%env(MONGODB_URL)%'
    database: '%env(MONGODB_DB)%'
    migrations_collection: migrations
    migrations_directory: '%kernel.project_dir%/migrations'
    migrations_namespace: 'App\Migrations'
```

`migrations_collection` defaults to `migrations`, but you can override it per application.

Architecture
------------

[](#architecture)

The bundle follows explicit layer separation:

- `src/Domain/` contains value objects and domain contracts.
- `src/Application/` contains use cases, result objects, and orchestration contracts.
- `src/Infrastructure/` contains MongoDB, filesystem, Symfony Console, and configuration adapters.
- `src/DependencyInjection/` contains Symfony bundle configuration and service wiring.
- `src/Migration/` contains the public migration contract used by generated migration classes.

`try/catch` is limited to entry points such as Symfony console commands. Application and Domain communicate through result objects instead of catching exceptions internally.

Migration Example
-----------------

[](#migration-example)

Generated migration classes implement `GeorgeBent\MongoDBMigrationsBundle\Migration\MigrationInterface` and use the `VersionYYYYMMDDHHMMSS` naming pattern.

Example:

```
