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(5y ago)02.0kMITPHPPHP &gt;=7.1CI failing

Since Dec 4Pushed 5y 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 today

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 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

2184d 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

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M35](/packages/scienta-doctrine-json-functions)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M154](/packages/sonata-project-doctrine-orm-admin-bundle)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[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.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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