5
5
Configuration
6
6
=============
7
7
8
- In the overview we already described the only necessary configuration option "mappings"
9
- to get the Doctrine ORM running with Symfony 2. All the other configuration options are
10
- used with reasonable default values.
8
+ In the overview we already described the only necessary configuration option
9
+ "mappings" to get the Doctrine ORM running with Symfony 2. All the other
10
+ configuration options are used with reasonable default values.
11
11
12
- This following configuration example shows all the configuration defaults that the ORM resolves to:
12
+ This following configuration example shows all the configuration defaults that
13
+ the ORM resolves to:
13
14
14
15
.. code-block :: yaml
15
16
@@ -25,11 +26,13 @@ This following configuration example shows all the configuration defaults that t
25
26
query_cache_driver : array
26
27
result_cache_driver : array
27
28
28
- There are lots of other configuration options that you can use to overwrite certain classes, but those
29
- are for very advanced use-cases only. You should look at the "orm.xml" file in the DoctrineBundle to
30
- get an overview of all the supported options.
29
+ There are lots of other configuration options that you can use to overwrite
30
+ certain classes, but those are for very advanced use-cases only. You should
31
+ look at the "orm.xml" file in the DoctrineBundle to get an overview of all the
32
+ supported options.
31
33
32
- For the caching drivers you can specifiy the values "array", "apc", "memcache" or "xcache".
34
+ For the caching drivers you can specifiy the values "array", "apc", "memcache"
35
+ or "xcache".
33
36
34
37
The following example shows an overview of the caching configurations:
35
38
@@ -49,35 +52,41 @@ The following example shows an overview of the caching configurations:
49
52
Mapping Configuration
50
53
~~~~~~~~~~~~~~~~~~~~~
51
54
52
- Explicit definition of all the mapped entities is the only necessary configuration for the ORM and there
53
- are several configuration options that you can control. The following configuration options exist
54
- for a mapping:
55
-
56
- - ``type `` One of "annotations", "xml", "yml", "php" or "static-php". This specifies which type
57
- of metadata type your mapping uses.
58
- - ``dir `` Path to the mapping or entity files (depending on the driver). If this path is relative
59
- it is assumed to be relative to the bundle root. This only works if the name of your mapping
60
- is a bundle name. If you want to use this option to specifiy absolute paths you should prefix
61
- the path with the kernel parameters that exist in the DIC (for example %kernel.dir%).
62
- - ``prefix `` A common namespace prefix that all entities of this mapping share. This prefix
63
- should never conflict with prefixes of other defined mappings otherwise some of your entities cannot be found
64
- by Doctrine. This option defaults to the bundle namespace + `Entities `, for example for an
65
- application bundle called "Hello" prefix would be "Application\H ello\E ntities".
66
- - ``alias `` Doctrine offers a way to alias entity namespaces to simpler, shorter names to be used
67
- in DQL queries or for Repository access.
68
- - ``is_bundle `` This option is a derived value from ``dir `` and by default is set to true if dir is relative
69
- proved by a ``file_exists() `` check that returns false. It is false if the existance check returns true.
70
- In this case an absolute path was specified and the metadata files are most likely in a directory outside of
71
- a bundle.
72
-
73
- To avoid having to configure lots of information for your mappings you should follow these conventions:
74
-
75
- 1. Put all your entities in a directory Entities/ inside your bundle. For example "Application/Hello/Entities/".
76
- 2. If you are using xml, yml or php mapping put all your configuration files into the
77
- "Resources/config/doctrine/metadata/doctrine/orm/" directory sufficed with dcm.xml, dcm.yml or dcm.php
78
- respectively.
79
- 3. Annotations is assumed if an "Entities/" but no "Resources/config/doctrine/metadata/doctrine/orm/"
80
- directory is found.
55
+ Explicit definition of all the mapped entities is the only necessary
56
+ configuration for the ORM and there are several configuration options that you
57
+ can control. The following configuration options exist for a mapping:
58
+
59
+ - ``type `` One of "annotations", "xml", "yml", "php" or "static-php". This
60
+ specifies which type of metadata type your mapping uses.
61
+ - ``dir `` Path to the mapping or entity files (depending on the driver). If
62
+ this path is relative it is assumed to be relative to the bundle root. This
63
+ only works if the name of your mapping is a bundle name. If you want to use
64
+ this option to specifiy absolute paths you should prefix the path with the
65
+ kernel parameters that exist in the DIC (for example %kernel.dir%).
66
+ - ``prefix `` A common namespace prefix that all entities of this mapping
67
+ share. This prefix should never conflict with prefixes of other defined
68
+ mappings otherwise some of your entities cannot be found by Doctrine. This
69
+ option defaults to the bundle namespace + `Entities `, for example for an
70
+ application bundle called "Hello" prefix would be
71
+ "Application\H ello\E ntities".
72
+ - ``alias `` Doctrine offers a way to alias entity namespaces to simpler,
73
+ shorter names to be used in DQL queries or for Repository access.
74
+ - ``is_bundle `` This option is a derived value from ``dir `` and by default is
75
+ set to true if dir is relative proved by a ``file_exists() `` check that
76
+ returns false. It is false if the existance check returns true. In this case
77
+ an absolute path was specified and the metadata files are most likely in a
78
+ directory outside of a bundle.
79
+
80
+ To avoid having to configure lots of information for your mappings you should
81
+ follow these conventions:
82
+
83
+ 1. Put all your entities in a directory Entities/ inside your bundle. For
84
+ example "Application/Hello/Entities/".
85
+ 2. If you are using xml, yml or php mapping put all your configuration files
86
+ into the "Resources/config/doctrine/metadata/doctrine/orm/" directory sufficed
87
+ with dcm.xml, dcm.yml or dcm.php respectively.
88
+ 3. Annotations is assumed if an "Entities/" but no
89
+ "Resources/config/doctrine/metadata/doctrine/orm/" directory is found.
81
90
82
91
The following configuration shows a bunch of mapping examples:
83
92
@@ -102,9 +111,9 @@ The following configuration shows a bunch of mapping examples:
102
111
Multiple Entity Managers
103
112
~~~~~~~~~~~~~~~~~~~~~~~~
104
113
105
- You can use multiple EntityManagers in a Symfony application. This is necessary
106
- if you are using different databases or even vendors with entirely different sets
107
- of entities.
114
+ You can use multiple EntityManagers in a Symfony application. This is
115
+ necessary if you are using different databases or even vendors with entirely
116
+ different sets of entities.
108
117
109
118
The following configuration code shows how to define two EntityManagers:
110
119
@@ -119,9 +128,9 @@ The following configuration code shows how to define two EntityManagers:
119
128
customer :
120
129
connection : customer
121
130
122
- Just like the DBAL, if you have configured multiple ``EntityManager `` instances
123
- and want to get a specific one you can use the full service name to retrieve
124
- it from the Symfony Dependency Injection Container:
131
+ Just like the DBAL, if you have configured multiple ``EntityManager ``
132
+ instances and want to get a specific one you can use the full service name to
133
+ retrieve it from the Symfony Dependency Injection Container: :
125
134
126
135
class UserController extends Controller
127
136
{
@@ -136,5 +145,5 @@ it from the Symfony Dependency Injection Container:
136
145
}
137
146
}
138
147
139
- The service "doctrine.orm.entity_manager" is an alias for the default entity manager
140
- defined in the "default_entity_manager" configuration option.
148
+ The service "doctrine.orm.entity_manager" is an alias for the default entity
149
+ manager defined in the "default_entity_manager" configuration option.
0 commit comments