The Simple PHP YAML Class.
This class can be used to read a YAML file and convert its contents into a PHP array. It currently supports a very limited subsection of the YAML spec.
Usage:
$Spyc = new Spyc;
$array = $Spyc->load($file);
or:
$array = Spyc::YAMLLoad($file);
or:
$array = spyc_load_file($file);
| package | Spyc |
|---|
YAMLDump(array $array, int $indent, int $wordwrap) : string
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as nothing.yaml and pass it around.
Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.
Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
| access | public |
|---|
arrayPHP array
intPass in false to use the default, which is 2
intPass in 0 for no wordwrap, false for default (40)
stringYAMLLoad(string $input) : array
The load method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array. Pretty simple. Usage:
$array = Spyc::YAMLLoad('lucky.yaml');
print_r($array);
| access | public |
|---|
stringPath of YAML file or string containing YAML
arrayYAMLLoadString(string $input) : array
The load method, when supplied with a YAML string, will do its best to convert YAML in a string into a PHP array. Pretty simple.
Note: use this function if you don't want files from the file system loaded and processed as YAML. This is of interest to people concerned about security whose input is from a string.
Usage:
$array = Spyc::YAMLLoadString("---\n0: hello world\n");
print_r($array);
| access | public |
|---|
stringString containing YAML
arraydump(array $array, int $indent, int $wordwrap) : string
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as tasteful.yaml and pass it around.
Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.
Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
| access | public |
|---|
arrayPHP array
intPass in false to use the default, which is 2
intPass in 0 for no wordwrap, false for default (40)
stringload(string $input) : array
string
arrayloadFile(string $file) : array
string
arrayrevertLiteralPlaceHolder($lineArray, $literalBlock)
__load($input)
__loadString($input)
_doFolding($value, $indent) : string
| access | private |
|---|
The string you wish to fold
string_doLiteralBlock($value, $indent) : string
| access | private |
|---|
int The value of the indent
string_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array) : string
| access | private |
|---|
The name of the key
The value of the item
The indent of the current node
string_inlineEscape($inline) : array
| access | private |
|---|
array_parseLine(string $line) : array
| access | private |
|---|
stringA line from the YAML file
array_toType(string $value) : mixed
| access | private |
|---|
string
mixed_yamlize($key, $value, $indent, $previous_key, $first_key, $source_array) : string
| access | private |
|---|
The name of the key
The value of the item
The indent of the current node
string_yamlizeArray($array, $indent) : string
| access | private |
|---|
The array you want to convert
The indent of the current level
stringaddArray($incoming_data, $incoming_indent)
addArrayInline($array, $indent)
addGroup($line, $group)
addLiteralLine($literalBlock, $line, $literalBlockStyle, $indent)
clearBiggerPathValues($indent)
getParentPathByIndent($indent)
greedilyNeedNextLine($line)
isArrayElement($line)
isComment($line)
isEmpty($line)
isHashElement($line)
isLiteral($line)
isPlainArray($line)
literalBlockContinues($line, $lineIndent)
loadFromSource($input)
loadFromString($input)
loadWithSource($Source)
nodeContainsGroup($line)
referenceContentsByAlias($alias)
returnArrayElement($line)
returnKeyValuePair($line)
returnMappedSequence($line)
returnMappedValue($line)
returnPlainArray($line)
startsLiteralBlock($line)
startsMappedSequence($line)
startsMappedValue($line)
stripGroup($line, $group)
stripIndent($line, $indent)
unquote($value)
$_nodeId
$setting_dump_force_quotes : bool
False by default.
$setting_use_syck_is_possible : bool
False by default.
$LiteralPlaceHolder
$SavedGroups
$_containsGroupAlias
$_containsGroupAnchor
$_dumpIndent
$_dumpWordWrap
$delayedPath : array
$indent
$path
$result
REMPTY