function Parser::parseFile
Parses a YAML file into a PHP value.
Parameters
string $filename The path to the YAML file to be parsed:
int-mask-of<Yaml::PARSE_*> $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior:
Throws
ParseException If the file could not be read or the YAML is not valid
File
-
vendor/
symfony/ yaml/ Parser.php, line 50
Class
- Parser
- Parser parses YAML strings to convert them to PHP arrays.
Namespace
Symfony\Component\YamlCode
public function parseFile(string $filename, int $flags = 0) : mixed {
if (!is_file($filename)) {
throw new ParseException(\sprintf('File "%s" does not exist.', $filename));
}
if (!is_readable($filename)) {
throw new ParseException(\sprintf('File "%s" cannot be read.', $filename));
}
$this->filename = $filename;
try {
return $this->parse(file_get_contents($filename), $flags);
} finally {
$this->filename = null;
}
}