class Yaml (View source)

Yaml offers convenience methods to load and dump YAML.

Constants

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

PARSE_KEYS_AS_STRINGS

Methods

static mixed
parse(string $input, int $flags = 0)

Parses YAML into a PHP value.

Details

static mixed parse(string $input, int $flags = 0)

Parses YAML into a PHP value.

Usage: $array = Yaml::parse(file_get_contents('config.yml')); print_r($array);

Parameters

string $input A string containing YAML
int $flags A bit field of PARSE_* constants to customize the YAML parser behavior

Return Value

mixed The YAML converted to a PHP value

Exceptions

ParseException If the YAML is not valid