\Horde_Yaml

Horde YAML parser.

This class can be used to read a YAML file and convert its contents into a PHP array. The native PHP parser supports a limited subsection of the YAML spec, but if the syck extension is present, that will be used for parsing.

Summary

Methods
Properties
Constants
load()
loadFile()
loadStream()
dump()
$loadfunc
$dumpfunc
$allowedClasses
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$loadfunc

$loadfunc : callback

Callback used for alternate YAML loader, typically exported by a faster PHP extension. This function's first argument must accept a string with YAML content.

Type

callback

$dumpfunc

$dumpfunc : callback

Callback used for alternate YAML dumper, typically exported by a faster PHP extension. This function's first argument must accept a mixed variable to be dumped.

Type

callback

$allowedClasses

$allowedClasses : array

Whitelist of classes that can be instantiated automatically when loading YAML docs that include serialized PHP objects.

Type

array

Methods

load()

load(string  $yaml) : array

Load a string containing YAML and parse it into a PHP array.

Returns an empty array on failure.

Parameters

string $yaml

String containing YAML

Returns

array —

PHP array representation of YAML content

loadFile()

loadFile(string  $filename) : array

Load a file containing YAML and parse it into a PHP array.

If the file cannot be opened, an exception is thrown. If the file is read but parsing fails, an empty array is returned.

Parameters

string $filename

Filename to load

Throws

\IllegalArgumentException

If $filename is invalid

\Horde_Yaml_Exception

If the file cannot be opened.

Returns

array —

PHP array representation of YAML content

loadStream()

loadStream(resource  $stream) : array

Load YAML from a PHP stream resource.

Parameters

resource $stream

PHP stream resource

Returns

array —

PHP array representation of YAML content

dump()

dump(  $value, array  $options = array()) : string

Dumps a PHP array to YAML.

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

Parameters

$value
array $options

Options to pass to dumper.

Returns

string —

YAML representation of $value.