PHPackages                             zaeder/multidb-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. zaeder/multidb-bundle

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

zaeder/multidb-bundle
=====================

Symfony MultiDbBundle

023PHP

Since Jul 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/zaeder/multidb-bundle)[ Packagist](https://packagist.org/packages/zaeder/multidb-bundle)[ RSS](/packages/zaeder-multidb-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

multidb-bundle
==============

[](#multidb-bundle)

A symfony 4 bundle with a local database and dynamic dist database

Use a local database for application configuration and a separate database per client

Install
-------

[](#install)

```
composer require zaeder/multidb-bundle

```

Create the entities
-------------------

[](#create-the-entities)

You must create 3 entities :

- For local database :
    - Server implements Zaeder\\MultiDbBundle\\Entity\\ServerInterface having for repository Zaeder\\MultiDbBundle\\Repository\\ServerRepository or an extended class
    - User implements Zaeder\\MultiDbBundle\\Entity\\LocalUserInterface having for repository Zaeder\\MultiDbBundle\\Repository\\LocalUserRepository or an extended class
- For dist database :
    - User implements Zaeder\\MultiDbBundle\\Entity\\DistUserInterface having for repository Zaeder\\MultiDbBundle\\Repository\\DistUserRepository or an extended class

We recommend to separate your entities and repositories in to folders Local and Dist

Configure
---------

[](#configure)

You need to define two connections and entity manager in doctrine configuration. We recommend using the connection for the client database by default, it will be easier for the autowiring. Use the same configuration as the local connection as default, it will be reconfigured on login

Add to your configuration :

```
multi_db:
  local:
    connection: localConnectionName
    entityManager: localEntityManagerName
    tablePrefix: '' #optional
    serverEntity: pathToServerEntity
    userEntity: pathToLocalUserEntity
  dist:
    connection: distConnectionName
    entityManager: distEntityManagerName
    tablePrefix: '' #optional
    userEntity: pathToDistUserEntity
  passwordKey: enterAnHash #better to define in .env or parameters.yml
  loginRedirect:
    - {role: 'roleName', route: 'routeName'} # Define higher role first

```

Add the bundle definition in config/bundles.php :

```
Zaeder\MultiDbBundle\MultiDbBundle::class => ['all' => true],

```

Edit the config/packages/security.yaml :

```
 security:
   encoders:
     pathToLocalUserEntity:
       algorithm: bcrypt
   providers:
     users:
       entity: pathToLocalUserEntity
       property: 'username'
       manager_name: 'localEntityManagerName'
   firewalls:
     [...]
     local:
       pattern: ^/
       anonymous: true
       providers: users
       guard:
         authenticators:
           - Zaeder\MultiDbBundle\Security\Authentication\LoginFormAuthenticator
       logout:
         path: logout
   role_hierarchy:
     ROLE_ADMIN: [ROLE_ALLOWED_TO_SWITCH] #ROLE ADMIN is the the users without client database

```

The login form
--------------

[](#the-login-form)

The login form need the fields serverKey, username, password and \_csrf\_token

Donate
------

[](#donate)

[Click here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2NWVQEGTFWBBE&source=url)

Or use the QR Code

[![Paypal donation](https://camo.githubusercontent.com/c18b5feade842a3029c5174228b3cc193ff2840d0e212e3ff585c8d72e35ac4d/68747470733a2f2f6c68352e676f6f676c6575736572636f6e74656e742e636f6d2f3651713234456c4e79536f3138523167704151556c387765774345694b362d316c5069666a784a614a55496a654f4a2d64704a53623636304d6375416d5367797348366b41586b346c7958567674344d55462d323d77313932302d68383838)](https://camo.githubusercontent.com/c18b5feade842a3029c5174228b3cc193ff2840d0e212e3ff585c8d72e35ac4d/68747470733a2f2f6c68352e676f6f676c6575736572636f6e74656e742e636f6d2f3651713234456c4e79536f3138523167704151556c387765774345694b362d316c5069666a784a614a55496a654f4a2d64704a53623636304d6375416d5367797348366b41586b346c7958567674344d55462d323d77313932302d68383838)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6722fbfd35c8785200e9403071c957e2152b966b92207f667108b0a94e2f789f?d=identicon)[zaeder](/maintainers/zaeder)

---

Top Contributors

[![zaeder](https://avatars.githubusercontent.com/u/16778315?v=4)](https://github.com/zaeder "zaeder (28 commits)")

### Embed Badge

![Health badge](/badges/zaeder-multidb-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/zaeder-multidb-bundle/health.svg)](https://phpackages.com/packages/zaeder-multidb-bundle)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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