Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,9 @@ A map with default context options that will be used with each ``serialize`` and
call. This can be used for example to set the json encoding behavior by setting ``json_encode_options``
to a `json_encode flags bitmask`_.

You can inspect the :ref:`serializer context builders <serializer-using-context-builders>`
to discover the available settings.

php_errors
~~~~~~~~~~

Expand Down
7 changes: 5 additions & 2 deletions serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ configuration:
serializer:
default_context:
enable_max_depth: true
yaml_indentation: 2

.. code-block:: xml

<!-- config/packages/framework.xml -->
<framework:config>
<!-- ... -->
<framework:serializer>
<default-context enable-max-depth="true"/>
<default-context enable-max-depth="true" yaml-indentation="2"/>
</framework:serializer>
</framework:config>

Expand All @@ -146,11 +147,13 @@ configuration:
// config/packages/framework.php
use Symfony\Config\FrameworkConfig;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use Symfony\Component\Serializer\Encoder\YamlEncoder;

return static function (FrameworkConfig $framework) {
$framework->serializer()
->defaultContext([
AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true
AbstractObjectNormalizer::ENABLE_MAX_DEPTH => true,
YamlEncoder::YAML_INDENTATION => 2,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a build failure about this, but i don't understand it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea @Nyholm

])
;
};
Expand Down