PHP code example of xp-forge / yaml

1. Go to this page and download the library: Download xp-forge/yaml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xp-forge / yaml example snippets


use org\yaml\{YamlParser, FileInput};

$result= (new YamlParser())->parse(new FileInput('.travis.yml'));
// [
//   language => "php"
//   php => [7, 7.1, 7.2, 7.3, 7.4, "nightly"]
//   matrix => [
//     allow_failures => [[
//       php => "nightly"
//     ]]
//   ]
//   before_script => ["curl ...", ...]
//   script => ["sh xp-run xp.unittest.TestRunner src/test/php"]
// ]

use org\yaml\{YamlParser, FileInput};
use util\cmd\Console;

$parser= new YamlParser();
foreach ($parser->documents(new FileInput('objects.yml')) as $i => $document) {
  Console::writeLine('Document #', $i, ': ', $document);
}