Download the PHP package karol-dabrowski/doctrine-dynamic-connection without Composer
On this page you can find all versions of the php package karol-dabrowski/doctrine-dynamic-connection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download karol-dabrowski/doctrine-dynamic-connection
More information about karol-dabrowski/doctrine-dynamic-connection
Files in karol-dabrowski/doctrine-dynamic-connection
Package doctrine-dynamic-connection
Short Description Doctrine Dynamic Connection library allows you to modify database connection parameters at runtime
License MIT
Informations about the package doctrine-dynamic-connection
Doctrine Dynamic Connection
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
- PHP 7.3 or greater
Installation
To install Doctrine Dynamic Connection via Composer execute the following command:
Setup
To use the library features, you need to make two changes comparing to the basic Doctrine ORM configuration:
- Add
wrapperClass
parameter with the name ofDynamicConnectionWrapper
class as a value to the array of database connection parameters. For simplicity, use::class
keyword. - Create and instance of
DynamicEntityManager
and pass your default entity manager as a constructor argument.
Usage
The most important method of DynamicEntityManager
is modifyConnection()
. It takes five parameters, but none of them is required.
Only parameters with non-null value will be modified. If you call the method with no arguments, your connection parameters will not be changed. Pass null
when you don't want to change a particular parameter.
Author
Karol Dabrowski @kdabrowskidev
License
Released under the MIT license.
All versions of doctrine-dynamic-connection with dependencies
doctrine/common Version ^3.0
doctrine/dbal Version ^2.10.0
doctrine/orm Version ^2.8