Example #1
0
File: sf_yaml.php Project: yfix/yf
<?php 
$config = ['git_urls' => ['https://github.com/yfix/Yaml.git' => 'sf_yaml/'], 'autoload_config' => ['sf_yaml/' => 'Symfony\\Component\\Yaml'], 'manual' => function () {
    if (!function_exists('yaml_parse')) {
        function yaml_parse($input)
        {
            return \Symfony\Component\Yaml\Yaml::parse($input);
        }
    }
    if (!function_exists('yaml_dump')) {
        function yaml_dump($yaml)
        {
            return \Symfony\Component\Yaml\Yaml::dump($yaml);
        }
    }
}, 'example' => function () {
    $yaml_str = trim('
receipt:     Oz-Ware Purchase Invoice
date:        2012-08-06
customer:
    given:   Dorothy
    family:  Gale
		');
    $php_array = ['receipt' => 'Oz-Ware Purchase Invoice', 'date' => 1344200400, 'customer' => ['given' => 'Dorothy', 'family' => 'Gale']];
    var_export(yaml_parse($yaml_str));
    var_dump(yaml_dump($php_array));
}];
if ($return_config) {
    return $config;
}
require_once __DIR__ . '/_yf_autoloader.php';
new yf_autoloader($config);
Example #2
0
 protected function writeFile($data, $timeout = 0)
 {
     $data = yaml_dump($data);
     $bytes = file_put_contents($this->filename, $data, LOCK_EX);
     return $bytes && $bytes > 0;
 }