diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 46e6ef5c17a83..ea075a23f3425 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -79,6 +79,29 @@ public static function parse($input, $flags = 0) return $yaml->parse($input, $flags); } + /** + * Parses YAML file into a PHP value. + * + * Usage: + * + * $array = Yaml::parseFile('config.yml'); + * print_r($array); + * + * + * @param string $fileName A file containing YAML + * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior + * + * @return mixed The YAML converted to a PHP value + * + * @throws ParseException If the YAML is not valid + */ + public static function parseFile($fileName, $flags = 0) + { + $input = file_get_contents($fileName); + + return self::parse($input, $flags); + } + /** * Dumps a PHP value to a YAML string. *