@@ -315,6 +315,44 @@ The YAML specification defines some tags to set the type of any data explicitly:
315
315
Pz7Y6OjuDg4J+fn5OTk6enp
316
316
56enmleECcgggoBADs=
317
317
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
+
341
+ * ``!php/enum `` allows to use a PHP enum case. This tag takes the fully-qualified
342
+ class name of the enum case as its argument:
343
+
344
+ .. code-block :: yaml
345
+
346
+ data :
347
+ # You can use the typed enum case...
348
+ operator_type : !php/enum App\Operator\Enum\Type::Or
349
+ # ... or you can also use "->value" to directly use the value of a BackedEnum case
350
+ operator_type : !php/enum App\Operator\Enum\Type::Or->value
351
+
352
+ .. versionadded :: 6.2
353
+
354
+ The ``!php/enum `` tag was introduced in Symfony 6.2.
355
+
318
356
Unsupported YAML Features
319
357
~~~~~~~~~~~~~~~~~~~~~~~~~
320
358
@@ -332,3 +370,4 @@ The following YAML features are not supported by the Symfony Yaml component:
332
370
333
371
.. _`YAML 1.2 version specification` : https://yaml.org/spec/1.2/spec.html
334
372
.. _`ISO-8601` : https://www.iso.org/iso-8601-date-and-time-format.html
373
+ .. _`serialize()` : https://www.php.net/manual/en/function.serialize.php
0 commit comments