You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+45
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,51 @@ dama_doctrine_test:
108
108
connection_a: true
109
109
```
110
110
111
+
#### Controlling how connections are kept statically in the current php process
112
+
113
+
By default, every configured doctrine DBAL connection will have its own driver connection that is managed in the current php process.
114
+
In case you need to customize this behavior you can choose different "connection keys" that are used to select driver connections.
115
+
116
+
Example for 2 connections that will re-use the same driver connection instance:
117
+
118
+
```yaml
119
+
doctrine:
120
+
dbal:
121
+
connections:
122
+
default:
123
+
url: '%database.url1%'
124
+
125
+
foo:
126
+
url: '%database.url2%'
127
+
128
+
dama_doctrine_test:
129
+
connection_keys:
130
+
# assigning the same key will result in the same internal driver connection being re-used for both DBAL connections
131
+
default: custom_key
132
+
foo: custom_key
133
+
```
134
+
135
+
**Since v8.1.0**: For connections with read/write replicas the bundle will use the **same** underlying driver connection by default for the primary and also for replicas. This addresses an [issue](https://github.com/dmaicher/doctrine-test-bundle/issues/289) where inconsistencies happened when reading/writing to different connections. This can also be customized as follows:
136
+
137
+
```yaml
138
+
doctrine:
139
+
dbal:
140
+
connections:
141
+
default:
142
+
url: '%database.url%'
143
+
replicas:
144
+
replica_one:
145
+
url: '%database.url_replica%'
146
+
147
+
dama_doctrine_test:
148
+
connection_keys:
149
+
# assigning different keys will result in separate internal driver connection being used for primary and replica
150
+
default:
151
+
primary: custom_key_primary
152
+
replicas:
153
+
replica_one: custom_key_primary_replica
154
+
```
155
+
111
156
### Example
112
157
113
158
An example usage can be seen within the functional tests included in this bundle: https://github.com/dmaicher/doctrine-test-bundle/tree/master/tests
if (!$this->hasSavepointsEnabled($connectionDefinition)) {
66
73
thrownew \LogicException(sprintf('This bundle relies on savepoints for nested database transactions. You need to enable "use_savepoints" on the Doctrine DBAL config for connection "%s".', $name));
thrownew \InvalidArgumentException(sprintf('Configuring "%s" caches is not supported anymore. Upgrade to PSR-6 caches instead.', Cache::class));
132
159
} else {
133
160
thrownew \InvalidArgumentException(sprintf('Unsupported cache class "%s" found on service "%s".', $originalCacheServiceDefinition->getClass(), $cacheServiceId));
@@ -140,14 +167,15 @@ private function registerStaticCache(
0 commit comments