Yaml dump and parse methods
YAML is a serialization format most useful when human readability
is a consideration. It can be useful for configuration files, as
well as import and export functions.
This file is a front end for a separate YAML package present in the
vendor directory. The intent is to provide a consistent interface
no mater what underlying library is actually used.
At present, this class expects the symfony/yaml package.
Methods summary
public static
string|boolean
|
#
dump( mixed $var, integer $inline = 4, integer $indent = 4 )
Dump an PHP array as a YAML string
Dump an PHP array as a YAML string
Parameters
- $var
- Variable which will be dumped
- $inline
- Nesting level where you switch to inline YAML
- $indent
- Number of spaces to indent for nested nodes
Returns
string|boolean YAML string or false on error
|
public static
array|boolean
|
#
load( string $yamlString )
Load a YAML string into a PHP array
Load a YAML string into a PHP array
Parameters
- $yamlString
- YAML dump string
Returns
array|boolean PHP array or false on error
|
public static
array|boolean
|
#
read( string $yamlFile )
Read a file containing YAML into a PHP array
Read a file containing YAML into a PHP array
Parameters
- $yamlFile
- filename of YAML file
Returns
array|boolean PHP array or false on error
|
public static
integer|boolean
|
#
save( array $var, string $yamlFile, integer $inline = 4, integer $indent = 4 )
Save a PHP array as a YAML file
Save a PHP array as a YAML file
Parameters
- $var
- variable which will be dumped
- $yamlFile
- filename of YAML file
- $inline
- Nesting level where you switch to inline YAML
- $indent
- Number of spaces to indent for nested nodes
Returns
integer|boolean number of bytes written, or false on error
|
public static
string|boolean
|
#
dumpWrapped( mixed $var, integer $inline = 4, integer $indent = 4 )
Dump an PHP array as a YAML string with a php wrapper
Dump an PHP array as a YAML string with a php wrapper
The wrap is a php header that surrounds the yaml with section markers,
'---' and '...' along with php comment markers. The php wrapper keeps the
yaml file contents from being revealed by serving the file directly from
a poorly configured server.
Parameters
- $var
- Variable which will be dumped
- $inline
- Nesting level where you switch to inline YAML
- $indent
- Number of spaces to indent for nested nodes
Returns
string|boolean YAML string or false on error
|
public static
array|boolean
|
#
loadWrapped( string $yamlString )
Load a YAML string with a php wrapper into a PHP array
Load a YAML string with a php wrapper into a PHP array
The wrap is a php header that surrounds the yaml with section markers,
'---' and '...' along with php comment markers. The php wrapper keeps the
yaml file contents from being revealed by serving the file directly from
a poorly configured server.
Parameters
- $yamlString
- YAML dump string
Returns
array|boolean PHP array or false on error
|
public static
array|boolean
|
#
readWrapped( string $yamlFile )
Read a file containing YAML with a php wrapper into a PHP array
Read a file containing YAML with a php wrapper into a PHP array
The wrap is a php header that surrounds the yaml with section markers,
'---' and '...' along with php comment markers. The php wrapper keeps the
yaml file contents from being revealed by serving the file directly from
a poorly configured server.
Parameters
- $yamlFile
- filename of YAML file
Returns
array|boolean PHP array or false on error
|
public static
integer|boolean
|
#
saveWrapped( array $var, string $yamlFile, integer $inline = 4, integer $indent = 4 )
Save a PHP array as a YAML file with a php wrapper
Save a PHP array as a YAML file with a php wrapper
The wrap is a php header that surrounds the yaml with section markers,
'---' and '...' along with php comment markers. The php wrapper keeps the
yaml file contents from being revealed by serving the file directly from
a poorly configured server.
Parameters
- $var
- variable which will be dumped
- $yamlFile
- filename of YAML file
- $inline
- Nesting level where you switch to inline YAML
- $indent
- Number of spaces to indent for nested nodes
Returns
integer|boolean number of bytes written, or false on error
|
protected static
|
|