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)
- Use a
Reader to iterate over the resource data.
- Inside each iteration, use a
Normalizer to normalize the data to a
standard format.
- After getting all data, use a
Cacher to cache the data for future
loading.
Documentation
Read the documentation for more information., (*8)
, (*9)