wizaplace/php-etl
Composer 安装命令:
composer require wizaplace/php-etl
包简介
Extract, Transform and Load data using this PHP written migration library.
README 文档
README
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).
Versions and compatibility
- To benefit from the latest features and if you use PHP 8.1 and above: use the 2.3 version (and above) of the library.
- If you use older versions of PHP: 7.4 or 8.0, use the 2.2 version of the library.
- If you use older versions of PHP: 7.2 <= PHP <= 7.4, use the legacy 1.3.x version.
Changelog
See the changelog here
Installation
In your application's folder, run:
composer require wizaplace/php-etl
Example 🚈
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; // Get your database settings : $config = [ 'driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'database' => 'myDatabase', 'username' => 'foo', 'password' => 'bar', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ]; // Instanciate all the components (manually or automatically with DI) $manager = new Manager(new ConnectionFactory()); $manager->addConnection($config); $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 (optional).
services.yaml
Wizaplace\Etl\Etl: shared: false
How to contribute?
Below are some (not exhaustive) welcomed features for a 3.x version.
- Dropping support of older PHP versions.
- Type-hinting, rector...
- Putting PHPCS back on the project.
- Updating PHPUnit
- Improve code in order to remove some PHPStan exclusions.
Documentation 📓
The documentation is available in a subfolder of the repo, here.
License
WP-ETL is licensed under the MIT license.
Origin of the project
This project is a fork and an improvement of the marquine/php-etl project by Leonardo Marquine.
wizaplace/php-etl 适用场景与选型建议
wizaplace/php-etl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 102.51k 次下载、GitHub Stars 达 73, 最近一次更新时间为 2020 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「data」 「transform」 「extraction」 「extract」 「etl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wizaplace/php-etl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wizaplace/php-etl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wizaplace/php-etl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Behat package to transform human readable labels into selectors or page paths.
Transform data structures
The bundle for easy using json-rpc api on your project
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 102.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 74
- 点击次数: 31
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-09