Completed
Push — master ( ea75f3...6b8e06 )
by stéphane
03:22
created

example.php (1 issue)

1
<?php
2
require_once __DIR__.'/vendor/autoload.php';
0 ignored issues
show
Missing file doc comment
Loading history...
3
4
use \Dallgoot\Yaml\Yaml as Y;
5
6
/**
7
 * Display some use cases for Yaml library
8
 */
9
const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR;
10
11
/* USE CASE 1
12
* load and parse if file exists
13
*/
14
ini_set("auto_detect_line_endings", 1);
15
$content = file_get_contents('./tests/cases/parsing/multiline_quoted_with_blank.yml');//var_dump($content);
16
// $content = file_get_contents('./tests/cases/examples/Example_2_17.yml');//var_dump($content);
17
$yaml = Y::parse($content, null, 2);
18
// $yaml = Y::parseFile('./references/Example 2.27.yml', null, 1);
19
var_dump($yaml);
20
var_dump(json_encode($yaml, JSON_OPTIONS));
21
exit(0);
22
// USE CASE 2
23
$a = <<<EOF
24
sequence:
25
    - string_key: 1
26
EOF;
27
$b = <<<EOF
28
#2
29
mapping:
30
    string_key: 1
31
EOF;
32
var_dump(Y::parse($a));
33
var_dump(Y::parse($b));
34
35
// USE CASE 3
36
// $yamlObjList = [];
37
// $yloader = new Loader();
38
// foreach(['file1', 'file2', 'file3'] as $key => $fileName)
39
// {
40
//     $yamlObjList[] =  $yloader->load($fileName)->parse();
41
// }
42