PHPackages                             karol-dabrowski/doctrine-dynamic-connection - 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. karol-dabrowski/doctrine-dynamic-connection

ActiveLibrary[Database &amp; ORM](/categories/database)

karol-dabrowski/doctrine-dynamic-connection
===========================================

Doctrine Dynamic Connection library allows you to modify database connection parameters at runtime

v1.0.0(5y ago)102.0k↓33.3%1[2 issues](https://github.com/karol-dabrowski/doctrine-dynamic-connection/issues)MITPHPPHP &gt;=7.3

Since Feb 27Pushed 5y ago2 watchersCompare

[ Source](https://github.com/karol-dabrowski/doctrine-dynamic-connection)[ Packagist](https://packagist.org/packages/karol-dabrowski/doctrine-dynamic-connection)[ RSS](/packages/karol-dabrowski-doctrine-dynamic-connection/feed)WikiDiscussions master Synced 1mo ago

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

Doctrine Dynamic Connection
===========================

[](#doctrine-dynamic-connection)

[![Packagist Version](https://camo.githubusercontent.com/9756ad90a18dc0f68224239db84bae520612325888ef2af109f7e4ffaa4c1fd3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b61726f6c2d646162726f77736b692f646f637472696e652d64796e616d69632d636f6e6e656374696f6e3f6c6162656c3d56657273696f6e)](https://packagist.org/packages/karol-dabrowski/doctrine-dynamic-connection)[![GitHub Workflow Status - Tests](https://camo.githubusercontent.com/81d5295abd74c3849ca576fbf71a046c199e3b4b6086d8d414b3fdded7bdf5bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b61726f6c2d646162726f77736b692f646f637472696e652d64796e616d69632d636f6e6e656374696f6e2f54657374732f6d61737465723f6c6162656c3d5465737473)](https://github.com/karol-dabrowski/doctrine-dynamic-connection/actions/workflows/tests.yml?query=branch%3Amaster)[![GitHub Workflow Status - code analysis](https://camo.githubusercontent.com/a8aaf7a812a63b2631a4e447184aa5525b048d6038a165ff72c98b5ab225905a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b61726f6c2d646162726f77736b692f646f637472696e652d64796e616d69632d636f6e6e656374696f6e2f436f6465253230616e616c797369732f6d61737465723f6c6162656c3d436f6465253230616e616c79736973)](https://github.com/karol-dabrowski/doctrine-dynamic-connection/actions/workflows/code_analysis.yml?query=branch%3Amaster)[![License: MIT](https://camo.githubusercontent.com/f8c080ccc16145b1c939fbab1630589aa164f47df866f6362f82782d80a0b41f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b61726f6c2d646162726f77736b692f646f637472696e652d64796e616d69632d636f6e6e656374696f6e3f6c6162656c3d4c6963656e7365)](https://github.com/karol-dabrowski/doctrine-dynamic-connection/blob/master/LICENSE.md)

Doctrine Dynamic Connection is a library that allows you to dynamically reinitialize a database connection with different parameters. The library creates wrappers for `Connection` and `EntityManager` classes and extend their functionality.

### Requirements

[](#requirements)

- PHP 7.3 or greater

### Installation

[](#installation)

To install Doctrine Dynamic Connection via Composer execute the following command:

```
composer require karol-dabrowski/doctrine-dynamic-connection
```

### Setup

[](#setup)

To use the library features, you need to make two changes comparing to the basic [Doctrine ORM configuration](https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/tutorials/getting-started.html):

1. Add `wrapperClass` parameter with the name of `DynamicConnectionWrapper` class as a value to the array of database connection parameters. For simplicity, use `::class` keyword.
2. Create and instance of `DynamicEntityManager` and pass your default entity manager as a constructor argument.

```
