Create simple imports with the Extract, Transform, Load pattern.
composer require camillebaronnet/php-etl
<?php
namespace App;
use Camillebaronnet\ETL\Extractor\Csv;
use Camillebaronnet\ETL\Strategy\LayerStrategy;
use Camillebaronnet\ETL\Transformer\DateTime;
use Camillebaronnet\ETL\Transformer\Trim;
use Camillebaronnet\ETL\Loader\Json;
//...
$etl = (new LayerStrategy)
->extract(Csv::class, ['filename' => 'dump.php'])
->transform(Trim::class)
->transform(DateTime::class, ['format' => 'd/m/Y', 'fields' => ['createAt']])
;
echo $etl->load(Json::class);
//...
You can easily create your own custom Extractors, Transformers, Loader or Strategy by implementing the corresponding interface.
- ExtractInterface
- TransformInterface
- LoaderInterface, if you're using the LayerStrategy.
- StreamLoaderInterface, if you're using the StreamStrategy.
You also can create a custom Strategy by implementing the ETLInterface.