fr3on/php-etl
Composer 安装命令:
composer require fr3on/php-etl
包简介
A typed, lazy PHP 8.4+ data pipeline / ETL library.
README 文档
README
A modern, typed, and lazy PHP 8.4+ data pipeline library.
php-etl is a high-performance ETL (Extract, Transform, Load) library designed to handle massive datasets with a constant memory footprint. Using PHP Generators under the hood, it processes data row-by-row, ensuring even the largest pipelines remain memory-safe.
Features
- Lazy Evaluation: Entirely stream-based using Generators. Never materialize large arrays again.
- Typed Pipelines: Full support for PHPStan generics (
Pipeline<TIn, TOut>). - High-Performance Extractors: Built-in support for CSV and JSON Lines (ndjson) with zero memory overhead.
- Batching & Chunking: Efficiently process rows in batches using
chunk($size)orbatch($size). - Fluent API: Modern entry point via
Pipeline::create(). - Error Resilience: Configurable error policies (
COLLECT,SKIP,THROW) to manage row-level failures. - Bulk Loading: Built-in
BulkPdoLoaderfor high-performance database inserts. - Zero Dependencies: Lightweight core with no runtime dependencies.
Installation
composer require fr3on/php-etl
Usage
Basic Example
use Fr3on\Etl\Pipeline; use Fr3on\Etl\Extractor\CsvExtractor; use Fr3on\Etl\Sink\CallbackSink; Pipeline::create() ->extract(new CsvExtractor('transactions.csv')) ->filter(fn($row) => $row['status'] === 'SUCCESS') ->map(fn($row) => ['id' => $row['tx_id'], 'amt' => (float)$row['amount']]) ->into(new CallbackSink(fn($row) => print_r($row))) ->run();
Bulk Loading Example
use Fr3on\Etl\Loader\BulkPdoLoader; Pipeline::create() ->extract(new CsvExtractor('large_data.csv')) ->chunk(1000) ->load(new BulkPdoLoader($pdo, 'target_table')) ->run();
Performance
php-etl is built for extreme efficiency. Benchmarks on 100,000 rows demonstrate sub-second processing with a constant memory footprint.
| Extractor | Throughput | Peak Memory | Time (100k rows) |
|---|---|---|---|
| JsonExtractor (JSONL) | ~1,080,000 rows/sec | ~2.0 MB | 91 ms |
| CsvExtractor | ~730,000 rows/sec | ~2.0 MB | 136 ms |
Benchmarks run on standard hardware (PHP 8.4, Opcache off). Results may vary depending on row complexity.
Testing & Benchmarking
The core library is tested for memory safety and high throughput.
composer test # Run PHPUnit composer test:memory # Run with strict 32M memory limit composer analyse # Run PHPStan Level 9 composer bench # Run PHPBench
License
MIT License. See LICENSE for details.
fr3on/php-etl 适用场景与选型建议
fr3on/php-etl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 220 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pipeline」 「lazy」 「etl」 「typed」 「generators」 「php84」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fr3on/php-etl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fr3on/php-etl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fr3on/php-etl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Lazy loading for middleware and request handlers
Extract, Transform and Load data using PHP.
LazyPDO is a set of wrappers over PHP's standard PDO and PDOStatement classes. It enables lazy loading, serialization and decoration.
Pipeline
Pipeline.Common contains interfaces and shared classes used by various Pipeline components
A robust, configuration-driven ETL and data import framework for Laravel. Handles CSV/Excel streaming, queues, validation, and relationships.
统计信息
- 总下载量: 220
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-13