Skip to content

Latest commit

 

History

History

jphp-yaml-ext

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

jphp-yaml-ext

Library for working with yaml text format.

How to use?

  1. Read from string:
use std;

$data = str::parseAs('name: value', 'yaml');

echo $data['name']; // value.
  1. Write to string:
use std;

$yamlString = str::formatAs(['name' => 'value'], 'yaml');

echo $yamlString;
  1. Read from file:
use std;

$data = fs::parseAs('path/to/file.yml', 'yaml');
  1. Write to file:
use std;

fs::formatAs('path/to/file.yml', ['name' => 'value'], 'yaml');
  1. Read from stream:
use std;

$stream = Stream::of('http://example.com/file.yml');
$data = $stream->parseAs('yaml');
  1. Write to stream:
use std;

$stream = Stream::of('file.yml', 'w+');
$data = $stream->writeFormatted(['name' => 'value'], 'yaml');
$stream->close();