@@ -15,46 +15,96 @@ composer require camillebaronnet/php-etl
1515
1616## Usage
1717
18+ This example extract some Github's repositories, apply some transformations
19+
1820``` php
1921<?php
2022
21- namespace App;
22-
23+ use Camillebaronnet\ETL\Etl;
2324use Camillebaronnet\ETL\Extractor\Http;
24- use Camillebaronnet\ETL\Strategy\LayerStrategy ;
25+ use Camillebaronnet\ETL\Loader\DebugLoader ;
2526use Camillebaronnet\ETL\Transformer\DateTime;
26- use Camillebaronnet\ETL\Loader\Json ;
27+ use Camillebaronnet\ETL\Transformer\Decode ;
2728use Camillebaronnet\ETL\Transformer\Flatten;
28-
29- //...
30-
31- $etl = (new LayerStrategy)
32- ->extract(Http::class, [
33- 'url' => 'https://api.github.com/users/camillebaronnet/repos'
29+ use Camillebaronnet\ETL\Transformer\Map;
30+ use Camillebaronnet\ETL\Transformer\Sleep;
31+
32+ $etl = (new Etl)
33+ ->extract(Http::class, ['url' => 'https://api.github.com/users/camillebaronnet/repos'])
34+ ->add(Decode::class)
35+ ->add(Sleep::class, ['seconds' => .2])
36+ ->add(Flatten::class, ['glue' => '_'])
37+ ->add(Map::class, [
38+ 'fields' => [
39+ 'id',
40+ 'name',
41+ 'full_name' => 'fullName',
42+ 'owner_login' => 'ownerLogin',
43+ 'owner_url' => 'ownerUrl',
44+ 'url',
45+ 'ssh_url' => 'sshUrl',
46+ 'created_at' => 'createdAt'
47+ ]
3448 ])
35- ->transform(Flatten::class, [
36- 'glue' => '_'
49+ ->add(DateTime::class, [
50+ 'fields' => ['createdAt'],
51+ 'from' => 'Y-m-d\TH:i:s\Z',
52+ 'to' => 'd/m/Y',
3753 ])
38- ->transform(DateTime::class, ['format' => 'd/m/Y', 'fields' => ['createAt']])
3954;
4055
41- echo $etl->load(Json ::class);
56+ $etl->process(DebugLoader ::class);
4257
43- //...
4458```
4559
46- ## The different strategies
60+ ## The process explained
61+
62+ - ** EXTRACT :**
63+ Extract can output one or more items
64+
65+ - ** TRANFORM :**
66+ A transform step takes the result of the previous
67+ step (extractor or transformer) apply an operation and optionally
68+ split the input into several subsets of items (example with [ Decode] ( src/Transformer/Decode.php ) ).
69+
70+ - ** LOADER :**
71+ A loader can by placed at the end of the pipeline or between transformers.
72+ Several Loader can be setting up.
73+
74+ ## Collection
75+
76+ ### Extractors
77+
78+ | Name | Description|
79+ | ------| ------|
80+ | [ HTTP] ( src/Extractor/Http.php ) | Simple wrapper for the libCurl |
81+
82+ ### Transformers
83+
84+ | Name | Description|
85+ | ------| ------|
86+ | [ Decode] ( src/Transformer/Decode.php ) | Decode JSON, YAML, XML, CSV and more using Symfony's DecoderInterface |
87+ | [ Map] ( src/Transformer/Map.php ) | Rename, keep and remove some fields |
88+ | [ Flatten] ( src/Transformer/Flatten.php ) | Flattens a multi-dimensional collection into a single dimension |
89+ | [ Trim] ( src/Transformer/Trim.php ) | Strip whitespace from the beginning and end of a string |
90+ | [ Sleep] ( src/Transformer/Sleep.php ) | Delay execution |
91+ | [ DateTime] ( src/Transformer/DateTime.php ) | Parse/Convert dates |
92+
93+
94+ ### Loaders
95+
96+ | Name | Description|
97+ | ------| ------|
98+ | [ Debug] ( src/Loader/DebugLoader.php ) | Display items in output |
4799
48- <img src =" docs/diagram.svg " >
49100
50101## Extendable
51102
52103You can easily create your own custom Extractors,
53104Transformers, Loader or Strategy by implementing the corresponding interface.
54105
55- - [ ExtractInterface] ( src/Extractor/ExtractInterface.php )
56- - [ TransformInterface] ( src/Transformer/TransformInterface.php )
57- - [ LoaderInterface] ( src/Loader/LoaderInterface.php ) , if you're using the LayerStrategy.
58- - [ StreamLoaderInterface] ( src/Loader/StreamLoaderInterface.php ) , if you're using the StreamStrategy.
106+ - [ ExtractInterface] ( src/ExtractInterface.php )
107+ - [ TransformInterface] ( src/TransformInterface.php )
108+ - [ LoaderInterface] ( src/LoaderInterface.php )
59109
60- You also can create a custom Strategy by implementing the [ ETLInterface ] ( src/ETLInterface. php) .
110+ Submit yours. Send a [ pull-request ] ( https://github.com/camillebaronnet/ php-etl-framework/compare )
0 commit comments