1. Go to this page and download the library: Download germania-kg/yaml-services 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/ */
germania-kg / yaml-services example snippets
use Germania\YamlServices\YamlParserCallable;
// Instantiate
$parser = new YamlParserCallable;
// Do business, assuming YAML content string
$result = $parser( $yaml_content );
// Evaluate, usually Array [...]
print_r( $result );
use Germania\YamlServices\YamlFileParserCallable;
use Symfony\Component\Finder\Finder;
// Instantiate, passing a Symfony Finder
$finder = new Finder;
$finder = $finder->depth( 0 )->in( [ 'contents', '
use Germania\YamlServices\YamlParserCallable;
use Symfony\Component\Yaml;
$parser = new YamlParserCallable( Yaml::PARSE_OBJECT );
$parser = new YamlParserCallable( Yaml::PARSE_OBJECT, $psr3_logger );
// Or, use per-case parsing options:
$custom_flags = Yaml::PARSE_OBJECT | YAML::PARSE_OBJECT_FOR_MAP;
$result = $parser($yaml_content, $custom_flags);
print_r( $result );
use Germania\YamlServices\ YamlFileParserCallable;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Yaml;
// Configure your Finder
$finder = new Finder;
$finder = $finder->depth( 0 )->in( [ 'contents', ':PARSE_OBJECT | YAML::PARSE_OBJECT_FOR_MAP;
$result = $parser( "config.yaml", $custom_flags);
print_r( $result );
use Germania\YamlServices\PimpleServiceProvider;
// Have your Pimple Container ready...
$dic = new Pimple\Container;
// Instantiate and register
$yaml_services = new PimpleServiceProvider;
$dic->register( $yaml_services );
// To parse a string
$parser = $dic['Yaml.Parser'];
$result = $parser( "My YAML string" );
// To parse a file
$parser = $dic['Yaml.FileParser'];
$result = $parser( "config.yaml" );