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