Extract, Transform and Load data using this PHP written migration library.
Extract, Transform and Load data using PHP. This library provides classes and a workflow to allow you to extract data from various sources (CSV, DB...), one or many, then transform them before saving them in another format.
You can also easily add your custom classes (Extractors, Transformers and Loaders).
- To benefit from the last features, you need PHP >= 7.4 and use the 2.x version of the library.
- If you use older versions of PHP: 7.2 <= PHP <= 7.4, use the legacy 1.3.x version (still maintained for bugfixes).
See the changelog here
In your application's folder, run:
composer require wizaplace/php-etl
In the example below, we will extract data from a csv file, trim white spaces from the name and email columns and then insert the values into the users table:
use Wizaplace\Etl\Etl; use Wizaplace\Etl\Extractors\Csv; use Wizaplace\Etl\Transformers\Trim; use Wizaplace\Etl\Loaders\Insert; use Wizaplace\Etl\Database\Manager; use Wizaplace\Etl\Database\ConnectionFactory; $connexionFactory = new ConnectionFactory(); $manager = new Manager($connexionFactory); $etl = new Etl(); $extractor = new Csv(); $transformer = new Trim(); $loader = new Insert($manager); $etl->extract($extractor, '/path/to/users.csv') ->transform( $transformer, [Step::COLUMNS => ['name', 'email']] ) ->load($loader, 'users') ->run();
The library is fully compatible with any PHP project. For instance, with Symfony, you can fully benefit from the autowiring. On the following example, you enable it on the main ETL object, with the shared parameter to false in order to have the possibility to get different instance of the ETL (optionnal).
Wizaplace\Etl\Etl: shared: false
The documentation is available in a subfolder of the repo, here.
WP-ETL is licensed under the MIT license.