cyve / etl
Extract-Transform-Load service
Installs: 518
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/cyve/etl
Requires
- php: >=8.1
- psr/event-dispatcher: ^1.0
- psr/log: ^1|^2|^3
Requires (Dev)
- phpunit/phpunit: ^10.0
- symfony/var-dumper: ^6.0
README
Installation:
With Composer:
composer require cyve/etl
Usage
Use case: convert CSV to JSON
$etl = new ETL( new CsvFileExtractor('users.csv'), new NullTransformer(), new JsonFileLoader('users.json') ); $etl->start();
Use an event dispatcher
Use the 4th argument of the constructor to inject an instance of Psr\EventDispatcher\EventDispatcherInterface.
At each step of each iteration, the ETL will dispatch an event containing the result if the operation succeeded, or an exception if the operation failed
$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher(); $etl = new ETL( $extractor, $transformer, $loader, $eventDispatcher, ); $etl->start();
Example: progress bar
$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$eventDispatcher->addListener(LoadSuccessEvent::class, function (LoadSuccessEvent $event): void {
echo '#';
});
$eventDispatcher->addListener(LoadFailureEvent::class, function (LoadFailureEvent $event): void {
echo 'E';
});