|
2 | 2 | single: Doctrine; ORM configuration reference |
3 | 3 | single: Configuration reference; Doctrine ORM |
4 | 4 |
|
5 | | -DoctrineBundle Configuration ("doctrine") |
6 | | -========================================= |
| 5 | +Doctrine Configuration Reference (DoctrineBundle) |
| 6 | +================================================= |
7 | 7 |
|
8 | | -Full Default Configuration |
9 | | --------------------------- |
10 | | - |
11 | | -.. configuration-block:: |
| 8 | +The DoctrineBundle integrates both the :doc:`DBAL </doctrine/dbal>` and |
| 9 | +:doc:`ORM </doctrine>` Doctrine projects in Symfony applications. All these |
| 10 | +options are configured under the ``doctrine`` key in your application |
| 11 | +configuration. |
12 | 12 |
|
13 | | - .. code-block:: yaml |
| 13 | +.. code-block:: terminal |
14 | 14 |
|
15 | | - # config/packages/doctrine.yaml |
16 | | - doctrine: |
17 | | - dbal: |
18 | | - default_connection: default |
19 | | - types: |
20 | | - # A collection of custom types |
21 | | - # Example |
22 | | - some_custom_type: |
23 | | - class: App\DBAL\MyCustomType |
24 | | - commented: true |
25 | | -
|
26 | | - connections: |
27 | | - # A collection of different named connections (e.g. default, conn2, etc) |
28 | | - default: |
29 | | - dbname: ~ |
30 | | - host: localhost |
31 | | - port: ~ |
32 | | - user: root |
33 | | - password: ~ |
34 | | - # charset of the database |
35 | | - charset: ~ |
36 | | - # charset and collation of the tables. Not inherited from database |
37 | | - default_table_options: |
38 | | - charset: ~ |
39 | | - collate: ~ |
40 | | - path: ~ |
41 | | - memory: ~ |
42 | | -
|
43 | | - # The unix socket to use for MySQL |
44 | | - unix_socket: ~ |
45 | | -
|
46 | | - # True to use as persistent connection for the ibm_db2 driver |
47 | | - persistent: ~ |
48 | | -
|
49 | | - # The protocol to use for the ibm_db2 driver (default to TCPIP if omitted) |
50 | | - protocol: ~ |
51 | | -
|
52 | | - # True to use dbname as service name instead of SID for Oracle |
53 | | - service: ~ |
54 | | -
|
55 | | - # The session mode to use for the oci8 driver |
56 | | - sessionMode: ~ |
57 | | -
|
58 | | - # True to use a pooled server with the oci8 driver |
59 | | - pooled: ~ |
60 | | -
|
61 | | - # Configuring MultipleActiveResultSets for the pdo_sqlsrv driver |
62 | | - MultipleActiveResultSets: ~ |
63 | | - driver: pdo_mysql |
64 | | - platform_service: ~ |
65 | | -
|
66 | | - # the version of your database engine |
67 | | - server_version: ~ |
68 | | -
|
69 | | - # when true, queries are logged to a 'doctrine' monolog channel |
70 | | - logging: '%kernel.debug%' |
71 | | - profiling: '%kernel.debug%' |
72 | | - driver_class: ~ |
73 | | - wrapper_class: ~ |
74 | | - # the DBAL keepSlave option |
75 | | - keep_slave: false |
76 | | - options: |
77 | | - # an array of options |
78 | | - key: [] |
79 | | - mapping_types: |
80 | | - # an array of mapping types |
81 | | - name: [] |
82 | | -
|
83 | | - # If defined, only the tables whose names match this regular expression are managed |
84 | | - # by the schema tool (in this example, any table name not starting with `wp_`) |
85 | | - #schema_filter: '/^(?!wp_)/' |
86 | | -
|
87 | | - slaves: |
88 | | -
|
89 | | - # a collection of named slave connections (e.g. slave1, slave2) |
90 | | - slave1: |
91 | | - dbname: ~ |
92 | | - host: localhost |
93 | | - port: ~ |
94 | | - user: root |
95 | | - password: ~ |
96 | | - charset: ~ |
97 | | - path: ~ |
98 | | - memory: ~ |
99 | | -
|
100 | | - # The unix socket to use for MySQL |
101 | | - unix_socket: ~ |
102 | | -
|
103 | | - # True to use as persistent connection for the ibm_db2 driver |
104 | | - persistent: ~ |
105 | | -
|
106 | | - # The protocol to use for the ibm_db2 driver (default to TCPIP if omitted) |
107 | | - protocol: ~ |
108 | | -
|
109 | | - # True to use dbname as service name instead of SID for Oracle |
110 | | - service: ~ |
111 | | -
|
112 | | - # The session mode to use for the oci8 driver |
113 | | - sessionMode: ~ |
114 | | -
|
115 | | - # True to use a pooled server with the oci8 driver |
116 | | - pooled: ~ |
117 | | -
|
118 | | - # Configuring MultipleActiveResultSets for the pdo_sqlsrv driver |
119 | | - MultipleActiveResultSets: ~ |
| 15 | + # displays the default config values defined by Symfony |
| 16 | + $ php bin/console config:dump-reference doctrine |
120 | 17 |
|
121 | | - orm: |
122 | | - default_entity_manager: ~ |
123 | | - auto_generate_proxy_classes: false |
124 | | - proxy_dir: '%kernel.cache_dir%/doctrine/orm/Proxies' |
125 | | - proxy_namespace: Proxies |
126 | | - # search for the "ResolveTargetEntityListener" class for an article about this |
127 | | - resolve_target_entities: [] |
128 | | - entity_managers: |
129 | | - # A collection of different named entity managers (e.g. some_em, another_em) |
130 | | - some_em: |
131 | | - query_cache_driver: |
132 | | - type: array # Required |
133 | | - host: ~ |
134 | | - port: ~ |
135 | | - instance_class: ~ |
136 | | - class: ~ |
137 | | - namespace: ~ |
138 | | - metadata_cache_driver: |
139 | | - type: array # Required |
140 | | - host: ~ |
141 | | - port: ~ |
142 | | - instance_class: ~ |
143 | | - class: ~ |
144 | | - namespace: ~ |
145 | | - result_cache_driver: |
146 | | - type: array # Required |
147 | | - host: ~ |
148 | | - port: ~ |
149 | | - instance_class: ~ |
150 | | - class: ~ |
151 | | - namespace: ~ |
152 | | - connection: ~ |
153 | | - class_metadata_factory_name: Doctrine\ORM\Mapping\ClassMetadataFactory |
154 | | - default_repository_class: Doctrine\ORM\EntityRepository |
155 | | - auto_mapping: false |
156 | | - hydrators: |
157 | | -
|
158 | | - # An array of hydrator names |
159 | | - hydrator_name: [] |
160 | | - mappings: |
161 | | - # An array of mappings, which may be a bundle name or something else |
162 | | - mapping_name: |
163 | | - mapping: true |
164 | | - type: ~ |
165 | | - dir: ~ |
166 | | - alias: ~ |
167 | | - prefix: ~ |
168 | | - is_bundle: ~ |
169 | | - dql: |
170 | | - # a collection of string functions |
171 | | - string_functions: |
172 | | - # example |
173 | | - # test_string: App\DQL\StringFunction |
174 | | -
|
175 | | - # a collection of numeric functions |
176 | | - numeric_functions: |
177 | | - # example |
178 | | - # test_numeric: App\DQL\NumericFunction |
179 | | -
|
180 | | - # a collection of datetime functions |
181 | | - datetime_functions: |
182 | | - # example |
183 | | - # test_datetime: App\DQL\DatetimeFunction |
184 | | -
|
185 | | - # Register SQL Filters in the entity manager |
186 | | - filters: |
187 | | - # An array of filters |
188 | | - some_filter: |
189 | | - class: ~ # Required |
190 | | - enabled: false |
191 | | -
|
192 | | - .. code-block:: xml |
193 | | -
|
194 | | - <!-- config/packages/doctrine.xml --> |
195 | | - <?xml version="1.0" encoding="UTF-8" ?> |
196 | | - <container xmlns="http://symfony.com/schema/dic/services" |
197 | | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
198 | | - xmlns:doctrine="http://symfony.com/schema/dic/doctrine" |
199 | | - xsi:schemaLocation="http://symfony.com/schema/dic/services |
200 | | - http://symfony.com/schema/dic/services/services-1.0.xsd |
201 | | - http://symfony.com/schema/dic/doctrine |
202 | | - http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> |
| 18 | + # displays the actual config values used by your application |
| 19 | + $ php bin/console debug:config doctrine |
203 | 20 |
|
204 | | - <doctrine:config> |
205 | | - <doctrine:dbal default-connection="default"> |
206 | | - <doctrine:connection |
207 | | - name="default" |
208 | | - dbname="database" |
209 | | - host="localhost" |
210 | | - port="1234" |
211 | | - user="user" |
212 | | - password="secret" |
213 | | - driver="pdo_mysql" |
214 | | - driver-class="App\DBAL\MyDatabaseDriver" |
215 | | - path="%kernel.project_dir%/var/data/data.sqlite" |
216 | | - memory="true" |
217 | | - unix-socket="/tmp/mysql.sock" |
218 | | - wrapper-class="App\DBAL\MyConnectionWrapper" |
219 | | - charset="UTF8" |
220 | | - logging="%kernel.debug%" |
221 | | - platform-service="App\DBAL\MyDatabasePlatformService" |
222 | | - server-version="5.6" |
223 | | - keep-slave="false" |
224 | | - > |
225 | | - <doctrine:option key="foo">bar</doctrine:option> |
226 | | - <doctrine:mapping-type name="enum">string</doctrine:mapping-type> |
227 | | - </doctrine:connection> |
228 | | - <doctrine:connection name="conn1" /> |
229 | | - <doctrine:type name="custom">App\DBAL\MyCustomType</doctrine:type> |
230 | | - </doctrine:dbal> |
| 21 | +.. note:: |
231 | 22 |
|
232 | | - <doctrine:orm |
233 | | - default-entity-manager="default" |
234 | | - auto-generate-proxy-classes="false" |
235 | | - proxy-namespace="Proxies" |
236 | | - proxy-dir="%kernel.cache_dir%/doctrine/orm/Proxies" |
237 | | - > |
238 | | - <doctrine:entity-manager |
239 | | - name="default" |
240 | | - query-cache-driver="array" |
241 | | - result-cache-driver="array" |
242 | | - connection="conn1" |
243 | | - class-metadata-factory-name="Doctrine\ORM\Mapping\ClassMetadataFactory" |
244 | | - > |
245 | | - <doctrine:metadata-cache-driver |
246 | | - type="memcache" |
247 | | - host="localhost" |
248 | | - port="11211" |
249 | | - instance-class="Memcache" |
250 | | - class="Doctrine\Common\Cache\MemcacheCache" |
251 | | - /> |
252 | | -
|
253 | | - <doctrine:mapping name="AcmeHelloBundle" /> |
254 | | -
|
255 | | - <doctrine:dql> |
256 | | - <doctrine:string-function name="test_string"> |
257 | | - App\DQL\StringFunction |
258 | | - </doctrine:string-function> |
259 | | -
|
260 | | - <doctrine:numeric-function name="test_numeric"> |
261 | | - App\DQL\NumericFunction |
262 | | - </doctrine:numeric-function> |
263 | | -
|
264 | | - <doctrine:datetime-function name="test_datetime"> |
265 | | - App\DQL\DatetimeFunction |
266 | | - </doctrine:datetime-function> |
267 | | - </doctrine:dql> |
268 | | - </doctrine:entity-manager> |
269 | | -
|
270 | | - <doctrine:entity-manager name="em2" connection="conn2" metadata-cache-driver="apc"> |
271 | | - <doctrine:mapping |
272 | | - name="DoctrineExtensions" |
273 | | - type="xml" |
274 | | - dir="%kernel.project_dir%/vendor/gedmo/doctrine-extensions/lib/DoctrineExtensions/Entity" |
275 | | - prefix="DoctrineExtensions\Entity" |
276 | | - alias="DExt" |
277 | | - /> |
278 | | - </doctrine:entity-manager> |
279 | | - </doctrine:orm> |
280 | | - </doctrine:config> |
281 | | - </container> |
| 23 | + When using XML, you must use the ``http://symfony.com/schema/dic/doctrine`` |
| 24 | + namespace and the related XSD schema is available at: |
| 25 | + ``http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd`` |
282 | 26 |
|
283 | 27 | .. index:: |
284 | 28 | single: Configuration; Doctrine DBAL |
|
0 commit comments