Yaml
in package
Yaml offers convenience methods to load and dump YAML.
Tags
Table of Contents
- DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024
- DUMP_EXCEPTION_ON_INVALID_TYPE = 16
- DUMP_MULTI_LINE_LITERAL_BLOCK = 128
- DUMP_NULL_AS_TILDE = 2048
- DUMP_OBJECT = 1
- DUMP_OBJECT_AS_MAP = 64
- PARSE_CONSTANT = 256
- PARSE_CUSTOM_TAGS = 512
- PARSE_DATETIME = 32
- PARSE_EXCEPTION_ON_INVALID_TYPE = 2
- PARSE_OBJECT = 4
- PARSE_OBJECT_FOR_MAP = 8
- dump() : string
- Dumps a PHP value to a YAML string.
- parse() : mixed
- Parses YAML into a PHP value.
- parseFile() : mixed
- Parses a YAML file into a PHP value.
Constants
DUMP_EMPTY_ARRAY_AS_SEQUENCE
public
mixed
DUMP_EMPTY_ARRAY_AS_SEQUENCE
= 1024
DUMP_EXCEPTION_ON_INVALID_TYPE
public
mixed
DUMP_EXCEPTION_ON_INVALID_TYPE
= 16
DUMP_MULTI_LINE_LITERAL_BLOCK
public
mixed
DUMP_MULTI_LINE_LITERAL_BLOCK
= 128
DUMP_NULL_AS_TILDE
public
mixed
DUMP_NULL_AS_TILDE
= 2048
DUMP_OBJECT
public
mixed
DUMP_OBJECT
= 1
DUMP_OBJECT_AS_MAP
public
mixed
DUMP_OBJECT_AS_MAP
= 64
PARSE_CONSTANT
public
mixed
PARSE_CONSTANT
= 256
PARSE_CUSTOM_TAGS
public
mixed
PARSE_CUSTOM_TAGS
= 512
PARSE_DATETIME
public
mixed
PARSE_DATETIME
= 32
PARSE_EXCEPTION_ON_INVALID_TYPE
public
mixed
PARSE_EXCEPTION_ON_INVALID_TYPE
= 2
PARSE_OBJECT
public
mixed
PARSE_OBJECT
= 4
PARSE_OBJECT_FOR_MAP
public
mixed
PARSE_OBJECT_FOR_MAP
= 8
Methods
dump()
Dumps a PHP value to a YAML string.
public
static dump(mixed $input[, int $inline = 2 ][, int $indent = 4 ], int $flags) : string
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.
Parameters
- $input : mixed
-
The PHP value
- $inline : int = 2
-
The level where you switch to inline YAML
- $indent : int = 4
-
The amount of spaces to use for indentation of nested nodes
- $flags : int
-
A bit field of DUMP_* constants to customize the dumped YAML string
Return values
string —parse()
Parses YAML into a PHP value.
public
static parse(string $input, int $flags) : mixed
Usage:
$array = Yaml::parse(file_get_contents('config.yml'));
print_r($array);
Parameters
- $input : string
-
A string containing YAML
- $flags : int
-
A bit field of PARSE_* constants to customize the YAML parser behavior
Tags
Return values
mixed —parseFile()
Parses a YAML file into a PHP value.
public
static parseFile(string $filename, int $flags) : mixed
Usage:
$array = Yaml::parseFile('config.yml'); print_r($array);
Parameters
- $filename : string
-
The path to the YAML file to be parsed
- $flags : int
-
A bit field of PARSE_* constants to customize the YAML parser behavior