Skip to content

Commit 84cbe90

Browse files
committed
Enhancing YAML parsing note - see #1541
1 parent b007e54 commit 84cbe90

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

components/yaml.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,22 @@ When loading a YAML file, it is sometimes better to use the
126126
127127
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML
128128
string or a file containing YAML. Internally, it calls the
129-
:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but with some added
130-
bonuses:
131-
132-
* When a file cannot be parsed, it automatically adds the file name to the
133-
error message, simplifying debugging when your application is loading
134-
several YAML files.
129+
:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but enhances the
130+
error if something goes wrong by adding the filename to the message.
131+
132+
Executing PHP Inside YAML Files
133+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134+
135+
.. versionadded:: 2.1
136+
The ``Yaml::enablePhpParsing()`` method is new to Symfony 2.1. Prior to 2.1,
137+
PHP was *always* executed when calling the ``parse()`` function.
138+
139+
By default, if you include PHP inside a YAML file, it will not be parsed.
140+
If you do want PHP to be parsed, you must call ``Yaml::enablePhpParsing()``
141+
before parsing the file to activate this mode. If you only want to allow
142+
PHP code for a single YAML file, be sure to disable PHP parsing after parsing
143+
the single file by calling ``Yaml::$enablePhpParsing = false;`` (``$enablePhpParsing``
144+
is a public property).
135145

136146
Writing YAML Files
137147
~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)