File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -126,12 +126,22 @@ When loading a YAML file, it is sometimes better to use the
126
126
127
127
The :method: `Symfony\\ Component\\ Yaml\\ Yaml::parse ` static method takes a YAML
128
128
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).
135
145
136
146
Writing YAML Files
137
147
~~~~~~~~~~~~~~~~~~
You can’t perform that action at this time.
0 commit comments