xp-forge / yaml
YAML parser
Installs: 19 366
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 1
Requires
- php: >=7.0.0
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
Usage example
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"] // ]
Inputs
org.yaml.FileInput(io.File|string $in)
- Use file instance or a file nameorg.yaml.ReaderInput(io.streams.TextReader $in)
- Reads from a text readerorg.yaml.StringInput(string $in)
- Input from a string
Multiple documents
YAML sources can contain more than one document. The parse()
method will only parse the first (or only) document. To retrieve all documents in a given input, use the iterator returned by documents()
instead.
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); }