Class

Symfony\Component\Yaml\Yaml

class Yaml

Yaml offers convenience methods to load and dump YAML.

Properties

static $enablePhpParsing Be warned that PHP support will be removed in Symfony 2.3.

Methods

static  enablePhpParsing()

Enables PHP support when parsing YAML files.

static  setPhpParsing(Boolean $boolean)

Sets the PHP support flag when parsing YAML files.

static Boolean supportsPhpParsing()

Checks if PHP support is enabled when parsing YAML files.

static array parse($input, $exceptionOnInvalidType = false, $objectSupport = false)

Parses YAML into a PHP array.

static string dump(array $array, integer $inline = 2, integer $indent = 2, Boolean $exceptionOnInvalidType = false, Boolean $objectSupport = false)

Dumps a PHP array to a YAML string.

Details

at line 39
static public enablePhpParsing()

Enables PHP support when parsing YAML files.

Be warned that PHP support will be removed in Symfony 2.3.

at line 53
static public setPhpParsing(Boolean $boolean)

Sets the PHP support flag when parsing YAML files.

Be warned that PHP support will be removed in Symfony 2.3.

Parameters

Boolean $boolean true if PHP parsing support is enabled, false otherwise

at line 67
static public Boolean supportsPhpParsing()

Checks if PHP support is enabled when parsing YAML files.

Be warned that PHP support will be removed in Symfony 2.3.

Return Value

Boolean true if PHP parsing support is enabled, false otherwise

at line 92
static public array parse($input, $exceptionOnInvalidType = false, $objectSupport = false)

Parses YAML into a PHP array.

The parse method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array.

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

Parameters

$input
$exceptionOnInvalidType
$objectSupport

Return Value

array The YAML converted to a PHP array

Exceptions

InvalidArgumentException If the YAML is not valid

at line 148
static public string dump(array $array, integer $inline = 2, integer $indent = 2, Boolean $exceptionOnInvalidType = false, Boolean $objectSupport = false)

Dumps a PHP array to a YAML string.

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.

Parameters

array $array PHP array
integer $inline The level where you switch to inline YAML
integer $indent The amount of spaces to use for indentation of nested nodes.
Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
Boolean $objectSupport true if object support is enabled, false otherwise

Return Value

string A YAML string representing the original PHP array