@@ -21,52 +21,6 @@ install the serializer before using it:
21
21
22
22
$ composer require serializer
23
23
24
- Then, enable the serializer in the framework config:
25
-
26
- .. configuration-block ::
27
-
28
- .. code-block :: yaml
29
-
30
- # config/packages/framework.yaml
31
- framework :
32
- # ...
33
- serializer : { enable_annotations: true }
34
- # Alternatively, if you don't want to use annotations
35
- # serializer: { enabled: true }
36
-
37
- .. code-block :: xml
38
-
39
- <!-- config/packages/framework.xml -->
40
- <?xml version =" 1.0" encoding =" UTF-8" ?>
41
- <container xmlns =" http://symfony.com/schema/dic/services"
42
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
43
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
44
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
45
- http://symfony.com/schema/dic/services/services-1.0.xsd
46
- http://symfony.com/schema/dic/symfony
47
- http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
48
- <framework : config >
49
- <!-- ... -->
50
- <framework : serializer enable-annotations =" true" />
51
- <!--
52
- Alternatively, if you don't want to use annotations
53
- <framework:serializer enabled="true" />
54
- -->
55
- </framework : config >
56
- </container >
57
-
58
- .. code-block :: php
59
-
60
- // config/packages/framework.php
61
- $container->loadFromExtension('framework', array(
62
- // ...
63
- 'serializer' => array(
64
- 'enable_annotations' => true,
65
- // Alternatively, if you don't want to use annotations
66
- //'enabled' => true,
67
- ),
68
- ));
69
-
70
24
Using the Serializer Service
71
25
----------------------------
72
26
@@ -148,46 +102,11 @@ Here is an example on how to load the
148
102
Using Serialization Groups Annotations
149
103
--------------------------------------
150
104
151
- Enable :ref: `serialization groups annotation <component-serializer-attributes-groups >`
152
- with the following configuration:
153
-
154
- .. configuration-block ::
155
-
156
- .. code-block :: yaml
157
-
158
- # config/packages/framework.yaml
159
- framework :
160
- # ...
161
- serializer :
162
- enable_annotations : true
163
-
164
- .. code-block :: xml
165
-
166
- <!-- config/packages/framework.xml -->
167
- <?xml version =" 1.0" encoding =" UTF-8" ?>
168
- <container xmlns =" http://symfony.com/schema/dic/services"
169
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
170
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
171
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
172
- http://symfony.com/schema/dic/services/services-1.0.xsd
173
- http://symfony.com/schema/dic/symfony
174
- http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
175
-
176
- <framework : config >
177
- <!-- ... -->
178
- <framework : serializer enable-annotations =" true" />
179
- </framework : config >
180
- </container >
105
+ To use annotations, first install the annotations package:
181
106
182
- .. code-block :: php
107
+ .. code-block :: terminal
183
108
184
- // config/packages/framework.php
185
- $container->loadFromExtension('framework', array(
186
- // ...
187
- 'serializer' => array(
188
- 'enable_annotations' => true,
189
- ),
190
- ));
109
+ $ composer require annotations
191
110
192
111
Next, add the :ref: `@Groups annotations <component-serializer-attributes-groups-annotations >`
193
112
to your class and choose which groups to use when serializing::
@@ -208,52 +127,11 @@ stored in one of the following locations:
208
127
209
128
.. _serializer-enabling-metadata-cache :
210
129
211
- Enabling the Metadata Cache
212
- ---------------------------
213
-
214
- Metadata used by the Serializer component such as groups can be cached to
215
- enhance application performance. Any service implementing the ``Doctrine\Common\Cache\Cache ``
216
- interface can be used.
217
-
218
- A service leveraging `APCu `_ (and APC for PHP < 5.5) is built-in.
219
-
220
- .. configuration-block ::
221
-
222
- .. code-block :: yaml
130
+ Configuring the Metadata Cache
131
+ ------------------------------
223
132
224
- # config/packages/prod/framework.yaml
225
- framework :
226
- # ...
227
- serializer :
228
- cache : serializer.mapping.cache.apc
229
-
230
- .. code-block :: xml
231
-
232
- <!-- config/packages/prod/framework.xml -->
233
- <?xml version =" 1.0" encoding =" UTF-8" ?>
234
- <container xmlns =" http://symfony.com/schema/dic/services"
235
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
236
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
237
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
238
- http://symfony.com/schema/dic/services/services-1.0.xsd
239
- http://symfony.com/schema/dic/symfony
240
- http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
241
-
242
- <framework : config >
243
- <!-- ... -->
244
- <framework : serializer cache =" serializer.mapping.cache.apc" />
245
- </framework : config >
246
- </container >
247
-
248
- .. code-block :: php
249
-
250
- // config/packages/prod/framework.php
251
- $container->loadFromExtension('framework', array(
252
- // ...
253
- 'serializer' => array(
254
- 'cache' => 'serializer.mapping.cache.apc',
255
- ),
256
- ));
133
+ The metadata for the serializer is automatically cached. To configure the cache,
134
+ configure the ``framework.cache.pools `` key in ``config/packages/framework.yaml ``.
257
135
258
136
Enabling a Name Converter
259
137
-------------------------