PHPackages                             gam6itko/doctrine-multibase-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. gam6itko/doctrine-multibase-bundle

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

gam6itko/doctrine-multibase-bundle
==================================

Allows to dynamically switch base doctrine connection to multiple instances

v0.2.1(6y ago)02.0kMITPHPPHP &gt;=7.1CI failing

Since Dec 4Pushed 6y ago1 watchersCompare

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

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

DoctrineMultibaseBundle
=======================

[](#doctrinemultibasebundle)

Allows to dynamically switch base doctrine connection to multiple instances.

Let's imagine that you have your own CRM. Which has many accounts. You want the data for each account to be stored in its own database. In this case, you need to have one connection that you could dynamically switch for the desired account. This library may come in handy here.

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

[](#installation)

```
composer require gam6itko/doctrine-multibase-bundle
```

Configure
---------

[](#configure)

First you need to configure switchable doctrine connection.

```
## doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
               # your system database connection which contains accounts
            account: # switchable connection
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name_account_prefix%"
                user:     "%database_user%"
                password: "%database_password%"

    orm:
        entity_managers:
            default:
                # something here
            account:
                connection: account # dynamic connection
                mappings:
                    AppAccountDataBundle: ~
```

Register connection switcher

```
# services.yaml

Gam6itko\MultibaseBundle\Doctrine\ConnectionSwitcher:
    public: true
    arguments: ['@doctrine.dbal.account_connection', '%database_name_account_prefix%']
    calls:
        - [setEventDispatcher, ['@event_dispatcher']]
```

Create database

```
php bin/console multibase:database:create account database_account 1917
php bin/console multibase:schema:create account database_account 1917
```

Finally switch dummy account connection to real when you need. For example do it on user login.

```
# services.yaml

App\EventListener\AccountConnectionListener:
    calls:
        - [setConnectionSwitcher, ['@Gam6itko\MultibaseBundle\Doctrine\ConnectionSwitcher']]
    tags:
        - {name: kernel.event_listener, event: kernel.request}
```

```
# App\EventListener\AccountConnectionListener

class AccountConnectionListener
{
    use ConnectionSwitcherAwareTrait;

    public function onKernelRequest(GetResponseEvent $event)
    {
        $user = $this->getUser();
        $this->connectionSwitcher->switchTo($user->getAccount()->getId());
    }
}
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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.

###  Release Activity

Cadence

Every ~82 days

Total

3

Last Release

2240d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3841197?v=4)[Alexander Strizhak](/maintainers/gam6itko)[@gam6itko](https://github.com/gam6itko)

---

Top Contributors

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

---

Tags

symfonydoctrinedynamic-database-connection

### Embed Badge

![Health badge](/badges/gam6itko-doctrine-multibase-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/gam6itko-doctrine-multibase-bundle/health.svg)](https://phpackages.com/packages/gam6itko-doctrine-multibase-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M387](/packages/easycorp-easyadmin-bundle)[sulu/sulu

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

1.3k1.4M204](/packages/sulu-sulu)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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