File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -120,20 +120,26 @@ error occurred:
120
120
As the parser is re-entrant, you can use the same parser object to load
121
121
different YAML strings.
122
122
123
- When loading a YAML file, it is sometimes better to use the
123
+ It may also be convenient to use the
124
124
:method: `Symfony\\ Component\\ Yaml\\ Yaml::parse ` wrapper method:
125
125
126
126
.. code-block :: php
127
127
128
128
use Symfony\Component\Yaml\Yaml;
129
129
130
- $yaml = Yaml::parse('/path/to/file.yml');
130
+ $yaml = Yaml::parse(file_get_contents( '/path/to/file.yml') );
131
131
132
132
The :method: `Symfony\\ Component\\ Yaml\\ Yaml::parse ` static method takes a YAML
133
133
string or a file containing YAML. Internally, it calls the
134
134
:method: `Symfony\\ Component\\ Yaml\\ Parser::parse ` method, but enhances the
135
135
error if something goes wrong by adding the filename to the message.
136
136
137
+ .. caution ::
138
+
139
+ Because it is currently possible to pass a filename to this method, you
140
+ must validate the input first. Passing a filename is deprecated in
141
+ Symfony 2.2, and will be removed in Symfony 3.0.
142
+
137
143
Executing PHP Inside YAML Files
138
144
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
145
You can’t perform that action at this time.
0 commit comments