8000 minor #8710 Fixing serializer config - much is now done automatically… · symfony/symfony-docs@8109be9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8109be9

Browse files
committed
minor #8710 Fixing serializer config - much is now done automatically (weaverryan)
This PR was squashed before being merged into the 4.0 branch (closes #8710). Discussion ---------- Fixing serializer config - much is now done automatically ping @javiereguiluz. The following is done automatically in 3.3 and higher: * serializer is automatically enabled when the component is present (when not using the full stack SE) * serializer annotations is automatically enabled when annotations is present * caching is handled by another system, and is enabled by default This should be merged into 4.0, because it's the only time that not using the full stack is standard... so effectively it only affects 4.0. Also, viva Flex and the new systems! Look how much config is removed :) Commits ------- 8634e40 typo cb31900 Fixing serializer config - much is now done automatically
2 parents 3e00ed1 + 8634e40 commit 8109be9

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>`
@@ -1660,20 +1659,6 @@ enabled
16601659

16611660
Whether to enable the ``serializer`` service or not in the service container.
16621661

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

16791664
enable_annotations

serializer.rst

Lines changed: 7 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,6 @@ install the serializer before using it:
2121
2222
$ composer require serializer
2323
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-
7024
Using the Serializer Service
7125
----------------------------
7226

@@ -148,46 +102,11 @@ Here is an example on how to load the
148102
Using Serialization Groups Annotations
149103
--------------------------------------
150104

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

182-
.. code-block:: php
107+
.. code-block:: terminal
183108
184-
// config/packages/framework.php
185-
$container->loadFromExtension('framework', array(
186-
// ...
187-
'serializer' => array(
188-
'enable_annotations' => true,
189-
),
190-
));
109+
$ composer require annotations
191110
192111
Next, add the :ref:`@Groups annotations <component-serializer-attributes-groups-annotations>`
193112
to your class and choose which groups to use when serializing::
@@ -208,52 +127,11 @@ stored in one of the following locations:
208127

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

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+
------------------------------
223132

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

258136
Enabling a Name Converter
259137
-------------------------

0 commit comments

Comments
 (0)
0