class Yaml
Yaml offers convenience methods to load and dump YAML.
DUMP_OBJECT | |
PARSE_EXCEPTION_ON_INVALID_TYPE | |
PARSE_OBJECT | |
PARSE_OBJECT_FOR_MAP | |
DUMP_EXCEPTION_ON_INVALID_TYPE | |
PARSE_DATETIME | |
DUMP_OBJECT_AS_MAP | |
DUMP_MULTI_LINE_LITERAL_BLOCK | |
PARSE_CONSTANT | |
PARSE_CUSTOM_TAGS | |
DUMP_EMPTY_ARRAY_AS_SEQUENCE |
static mixed | parseFile(string $filename, int $flags = 0) Parses a YAML file into a PHP value. | |
static mixed | parse(string $input, int $flags = 0) Parses YAML into a PHP value. | |
static string | dump(mixed $input, int $inline = 2, int $indent = 4, int $flags = 0) Dumps a PHP value to a YAML string. |
Parses a YAML file into a PHP value.
Usage:
$array = Yaml::parseFile('config.yml');
print_r($array);
string | $filename | The path to the YAML file to be parsed |
int | $flags | A bit field of PARSE_* constants to customize the YAML parser behavior |
mixed | The YAML converted to a PHP value |
ParseException | If the file could not be read or the YAML is not valid |
Parses YAML into a PHP value.
Usage:
$array = Yaml::parse(file_get_contents('config.yml'));
print_r($array);
string | $input | A string containing YAML |
int | $flags | A bit field of PARSE_* constants to customize the YAML parser behavior |
mixed | The YAML converted to a PHP value |
ParseException | If the YAML is not valid |
Dumps a PHP value to a YAML string.
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.
mixed | $input | The PHP value |
int | $inline | The level where you switch to inline YAML |
int | $indent | The amount of spaces to use for indentation of nested nodes |
int | $flags | A bit field of DUMP_* constants to customize the dumped YAML string |
string | A YAML string representing the original PHP value |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Yaml/Yaml.html