allmarkedup/dayglo

PHP 数据加载器。

v0.2.2 2015-03-13 10:28 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:33:46 UTC


README

PHP 5.4+ 的数据文件加载/解析器。

安装和使用

使用 composer

$ composer require allmarkedup/dayglo

示例

<?php

use Amu\Dayglo\Parser;
use Amu\Dayglo\Loader;
use Amu\Dayglo\ParserCollection;

// Create collection with the parsers required
$parsers = new ParserCollection([
    new Parser\JsonParser(),
    new Parser\YamlParser()
]);

$loader = new Loader($parsers, __DIR__ . '/data');

// load and parse data from a JSON file
$file = $loader->fetch('example.json');
$data = $file->getData();

// load and parse data from a YAML file
$file = $loader->fetch('test.yaml');
$data = $file->getData();