8000 Fixing serializer config - much is now done automatically · symfony/symfony-docs@cb31900 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb31900

Browse files
committed
Fixing serializer config - much is now done automatically
1 parent ab4410e commit cb31900

File tree

2 files changed

+7
-144
lines changed

2 files changed

+7
-144
lines changed

reference/configuration/framework.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ Configuration
106106
* `debug`_
107107
* `serializer`_
108108
* :ref:`enabled <reference-serializer-enabled>`
109-
* :ref:`cache <reference-serializer-cache>`
110109
* :ref:`enable_annotations <reference-serializer-enable_annotations>`
111110
* :ref:`name_converter <reference-serializer-name_converter>`
112111
* :ref:`circular_reference_handler <reference-serializer-circular_reference_handler>`
@@ -1656,20 +1655,6 @@ enabled
16561655

16571656
Whether to enable the ``serializer`` service or not in the service container.
16581657

1659-
.. _reference-serializer-cache:
1660-
1661-
cache
1662-
.....
1663-
1664-
**type**: ``string``
1665-
1666-
The service that is used to persist class metadata in a cache. The service
1667-
has to implement the ``Doctrine\Common\Cache\Cache`` interface.
1668-
1669-
.. seealso::
1670-
1671-
For more information, see :ref:`serializer-enabling-metadata-cache`.
1672-
16731658
.. _reference-serializer-enable_annotations:
16741659

16751660
enable_annotations

serializer.rst

Lines changed: 7 additions & 129 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,6 @@ Before using the serializer, run this command to install it in your application:
2020
2121
$ composer require serializer
2222
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-
6923
Using the Serializer Service
7024
----------------------------
7125

@@ -147,46 +101,11 @@ Here is an example on how to load the
147101
Using Serialization Groups Annotations
148102
--------------------------------------
149103

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:
180105

181-
.. code-block:: php
106+
.. code-block:: terminal
182107
183-
// config/packages/framework.php
184-
$container->loadFromExtension('framework', array(
185-
// ...
186-
'serializer' => array(
187-
'enable_annotations' => true,
188-
),
189-
));
108+
$ composer require annotations
190109
191110
Next, add the :ref:`@Groups annotations <component-serializer-attributes-groups-annotations>`
192111
to your class and choose which groups to use when serializing::
@@ -207,52 +126,11 @@ stored in one of the following locations:
207126

208127
.. _serializer-enabling-metadata-cache:
209128

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-
221-
.. code-block:: yaml
129+
Configruing the Metadata Cache
130+
------------------------------
222131

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``.
256134

257135
Enabling a Name Converter
258136
-------------------------

0 commit comments

Comments
 (0)
0