8000 minor #8687 Updated the serializer/* articles to Symfony 4 (javieregu… · symfony/symfony-docs@ab4410e · GitHub
[go: up one dir, main page]

Skip to content

Commit ab4410e

Browse files
committed
minor #8687 Updated the serializer/* articles to Symfony 4 (javiereguiluz)
This PR was squashed before being merged into the master branch (closes #8687). Discussion ---------- Updated the serializer/* articles to Symfony 4 Commits ------- b3ef6c3 Fixed a RST reference 57c539f Fixed a reference 453884f Updated the serializer/* articles to Symfony 4
2 parents 011740b + b3ef6c3 commit ab4410e

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

serializer.rst

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
How to Use the Serializer
55
=========================
66

7-
Serializing and deserializing to and from objects and different formats (e.g.
8-
JSON or XML) is a very complex topic. Symfony comes with a
9-
:doc:`Serializer Component </components/serializer>`, which gives you some
10-
tools that you can leverage for your solution.
7+
Symfony provides a serializer to serialize/deserialize to and from objects and
8+
different formats (e.g. JSON or XML). Before using it, read the
9+
:doc:`Serializer component docs </components/serializer>` to get familiar with
10+
its philosophy and the normalizers and encoders terminology.
1111

12-
In fact, before you start, get familiar with the serializer, normalizers
13-
and encoders by reading the :doc:`Serializer Component </components/serializer>`.
12+
.. _activating_the_serializer:
1413

15-
Activating the Serializer
14+
Installing the Serializer
1615
-------------------------
1716

18-
The ``serializer`` service is not available by default. To turn it on, activate
19-
it in your configuration:
17+
Before using the serializer, run this command to install it in your application:
18+
19+
.. code-block:: terminal
20+
21+
$ composer require serializer
22+
23+
Then, enable the serializer in the framework config:
2024

2125
.. configuration-block::
2226

@@ -65,7 +69,7 @@ it in your configuration:
6569
Using the Serializer Service
6670
----------------------------
6771

68-
Once enabled, the ``serializer`` service can be injected in any service where
72+
Once enabled, the serializer service can be injected in any service where
6973
you need it or it can be used in a controller::
7074

7175
// src/Controller/DefaultController.php
@@ -85,7 +89,7 @@ you need it or it can be used in a controller::
8589
Adding Normalizers and Encoders
8690
-------------------------------
8791

88-
Once enabled, the ``serializer`` service will be available in the container
92+
Once enabled, the serializer service will be available in the container
8993
and will be loaded with four :ref:`encoders <component-serializer-encoders>`
9094
(:class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder`,
9195
:class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder`,
@@ -193,12 +197,12 @@ to your class and choose which groups to use when serializing::
193197
);
194198

195199
In addition to the ``@Groups`` annotation, the Serializer component also
196-
supports Yaml or XML files. These files are automatically loaded when being
200+
supports YAML or XML files. These files are automatically loaded when being
197201
stored in one of the following locations:
198202

199-
* The ``serialization.yml`` or ``serialization.xml`` file in
203+
* The ``serialization.yaml`` or ``serialization.xml`` file in
200204
the ``Resources/config/`` directory of a bundle;
201-
* All ``*.yml`` and ``*.xml`` files in the ``Resources/config/serialization/``
205+
* All ``*.yaml`` and ``*.xml`` files in the ``Resources/config/serialization/``
202206
directory of a bundle.
203207

204208
.. _serializer-enabling-metadata-cache:
@@ -302,9 +306,9 @@ take a look at how this bundle works.
302306

303307
.. toctree::
304308
:maxdepth: 1
305-
:glob:
306309

307-
serializer/*
310+
serializer/encoders
311+
serializer/custom_encoders
308312

309313
.. _`APCu`: https://github.com/krakjoe/apcu
310314
.. _`ApiPlatform`: https://github.com/api-platform/core

serializer/custom_encoders.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ to use another structure that's not supported.
1515
Creating a new encoder
1616
----------------------
1717

18-
Imagine you want to serialize and deserialize Yaml. For that you'll have to
18+
Imagine you want to serialize and deserialize YAML. For that you'll have to
1919
create your own encoder that uses the
2020
:doc:`Yaml Component </components/yaml>`::
2121

@@ -53,13 +53,13 @@ Registering it in your app
5353

5454
If you use the Symfony Framework. then you probably want to register this encoder
5555
as a service in your app. If you're using the :ref:`default services.yml configuration <service-container-services-load-example>`,
56-
that's done automatically!
56+
that's done automatically!
5757

5858
.. tip::
5959

60-
If you're not using autoconfigure, make sure to register your class as a service
61-
and tag it with ``serializer.encoder``.
60+
If you're not using :ref:`autoconfigure <service_autoconfigure>`, make sure
61+
to register your class as a service and tag it with ``serializer.encoder``.
6262

63-
Now you'll be able to serialize and deserialize Yaml!
63+
Now you'll be able to serialize and deserialize YAML!
6464

6565
.. _tracker: https://github.com/symfony/symfony/issues

service_container/3.3-di-changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ In general, the new best practice is to use normal constructor dependency inject
408408
(or "action" injection in controllers) instead of fetching public services via
409409
``$this->get()`` (though that does still work).
410410

411+
.. _service_autoconfigure:
412+
411413
4) Auto-tagging with autoconfigure
412414
----------------------------------
413415

0 commit comments

Comments
 (0)
0