Skip to content

Commit d96e62e

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: [Yaml] Mention `php/const` and `php/object`
2 parents e6cacdf + aad5bf5 commit d96e62e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

reference/formats/yaml.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,29 @@ The YAML specification defines some tags to set the type of any data explicitly:
315315
Pz7Y6OjuDg4J+fn5OTk6enp
316316
56enmleECcgggoBADs=
317317
318+
Symfony Specific Features
319+
~~~~~~~~~~~~~~~~~~~~~~~~~
320+
321+
The Yaml component provides some additional features that are not part of the
322+
official YAML specification but are useful in Symfony applications:
323+
324+
* ``!php/const`` allows to get the value of a PHP constant. This tag takes the
325+
fully-qualified class name of the constant as its argument:
326+
327+
.. code-block:: yaml
328+
329+
data:
330+
page_limit: !php/const App\Pagination\Paginator::PAGE_LIMIT
331+
332+
* ``!php/object`` allows to pass the serialized representation of a PHP
333+
object (created with the `serialize()`_ function), which will be deserialized
334+
when parsing the YAML file:
335+
336+
.. code-block:: yaml
337+
338+
data:
339+
my_object: !php/object 'O:8:"stdClass":1:{s:3:"bar";i:2;}'
340+
318341
Unsupported YAML Features
319342
~~~~~~~~~~~~~~~~~~~~~~~~~
320343

@@ -332,3 +355,4 @@ The following YAML features are not supported by the Symfony Yaml component:
332355

333356
.. _`YAML 1.2 version specification`: https://yaml.org/spec/1.2/spec.html
334357
.. _`ISO-8601`: https://www.iso.org/iso-8601-date-and-time-format.html
358+
.. _`serialize()`: https://www.php.net/manual/en/function.serialize.php

0 commit comments

Comments
 (0)