Skip to content

[Yaml] Mention php/const and php/object #18083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
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
22 changes: 22 additions & 0 deletions reference/formats/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,28 @@ The YAML specification defines some tags to set the type of any data explicitly:
Pz7Y6OjuDg4J+fn5OTk6enp
56enmleECcgggoBADs=

Symfony Specific Tags
~~~~~~~~~~~~~~~~~~~~~

The YAML component provides a few additional tags that brings a few
features when parsed in your PHP code:

* ``!php/const`` allows to use a constant name defined in a PHP file. This
tag takes a constant FQCN as its argument:

.. code-block:: yaml

data:
page_limit: !php/const App\Pagination\Paginator::PAGE_LIMIT

* ``!php/object`` allows to pass the serialized representation of a PHP
object, which will be deserialized when the parsing is done:

.. code-block:: yaml

data:
my_object: !php/object 'O:8:"stdClass":1:{s:3:"bar";i:2;}'

Unsupported YAML Features
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down