2017 © Pedro Peláez
 

library resource

Provides tools to define and load resources

image

yosmanyga/resource

Provides tools to define and load resources

  • Tuesday, January 31, 2017
  • by yosmanyga
  • Repository
  • 1 Watchers
  • 1 Stars
  • 82 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Resource

This library provides tools to define and load resources., (*1)

A Resource is an object containing metadata that refers to something like a file, a directory, a db table or anything else with data:, (*2)

$resource = new Resource(array(
    'file' => '/path/to/a/file'
));

Reader

You can read a resource by using a Reader. The read is done usually iterating over the data at first level:, (*3)

resource.yml:, (*4)

item1:
    item11: value11
    item12: value12
item2:
    item22: value22

reader.php:, (*5)

$reader = new YamlFileReader();
$reader->open($resource);
while ($item = $reader->current()) {
    print_r($item);
    $reader->next();
}
$reader->close();

output:, (*6)

Array
(
    [key] => item1
    [value] => Array
        (
            [item11] => value11
            [item12] => value12
        )
)
Array
(
    [key] => item2
    [value] => Array
        (
            [item22] => value22
        )

)

Workflow

This library proposes a workflow for loading a resource:, (*7)

  1. Use a Reader to iterate over the resource data.
  2. Inside each iteration, use a Normalizer to normalize the data to a standard format.
  3. After getting all data, use a Cacher to cache the data for future loading.

Documentation

Read the documentation for more information., (*8)

Bitdeli Badge, (*9)

The Versions

31/01 2017

dev-master

9999999-dev

Provides tools to define and load resources

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Yosmany Garcia

resource loader reader