PHPackages                             bentools/etl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bentools/etl

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bentools/etl
============

PHP ETL (Extract / Transform / Load) implementation, with very few dependencies.

4.2.0(3mo ago)12750.5k↓17.6%31MITPHPPHP &gt;=8.2CI passing

Since Feb 11Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/bpolaszek/bentools-etl)[ Packagist](https://packagist.org/packages/bentools/etl)[ RSS](/packages/bentools-etl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (42)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/fde6f532ce29bc3d78cc4d915a268f0cec4ecc363187156818f0e572e4c5b1e8/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f65746c2f762f737461626c65)](https://packagist.org/packages/bentools/etl)[![License](https://camo.githubusercontent.com/a2fcdb566833e86cebc89291dd66ee266cc124929089b9334fc18502b4fc17ab/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f65746c2f6c6963656e7365)](https://packagist.org/packages/bentools/etl)[![CI Workflow](https://github.com/bpolaszek/bentools-etl/actions/workflows/ci.yml/badge.svg)](https://github.com/bpolaszek/bentools-etl/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/3ffa8f5afdc8898fed0f6a66e19c40fc688578dd3266e4f8d6e133dca3043bea/68747470733a2f2f636f6465636f762e696f2f67682f62706f6c61737a656b2f62656e746f6f6c732d65746c2f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4c35756c5461796d6274)](https://codecov.io/gh/bpolaszek/bentools-etl)[![Total Downloads](https://camo.githubusercontent.com/941dc22ba1f69fc66b678081bf67bc52ec0d00ff083dee0524788ecb7a29a713/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f65746c2f646f776e6c6f616473)](https://packagist.org/packages/bentools/etl)

Okay, so you heard about the [Extract / Transform / Load](https://en.wikipedia.org/wiki/Extract,_transform,_load) pattern, and you're looking for a PHP library to do the stuff. Alright, let's go!

`bentools/etl` is a versatile PHP library for implementing the Extract, Transform, Load (ETL) pattern, designed to streamline data processing tasks.

Table of Contents
-----------------

[](#table-of-contents)

- [Concepts](#concepts)
- [Installation](#installation)
- [Getting started](#usage)
    - [The EtlState object](doc/getting-started.md#the-etlstate-object)
    - [Skipping items](doc/getting-started.md#skipping-items)
    - [Stopping the workflow](doc/getting-started.md#stopping-the-workflow)
    - [Using events](doc/getting-started.md#using-events)
    - [Flush frequency and early flushes](doc/getting-started.md#flush-frequency-and-early-flushes)
- [Advanced Usage](doc/advanced_usage.md)
    - [Creating your own Extractor / Transformers / Loaders](doc/advanced_usage.md#creating-your-own-extractor--transformers--loaders)
    - [Difference between yield and return in transformers](doc/advanced_usage.md#difference-between-yield-and-return-in-transformers)
    - [Batch transforms](doc/advanced_usage.md#batch-transforms)
    - [Next tick](doc/advanced_usage.md#next-tick)
    - [Chaining extractors / transformers / loaders](doc/advanced_usage.md#chaining-extractors--transformers--loaders)
    - [Reading from STDIN / Writing to STDOUT](doc/advanced_usage.md#reading-from-stdin--writing-to-stdout)
    - [Instantiators](doc/advanced_usage.md#instantiators)
    - [Using ReactPHP](doc/advanced_usage.md#using-reactphp-experimental)
- [Recipes](doc/recipes.md)
- [Contributing](#contribute)
- [License](#license)

Concepts
--------

[](#concepts)

Let's cover the basic concepts:

- **Extract**: you have a source of data (a database, a CSV file, whatever) - an **extractor** is able to read that data and provide an iterator of items
- **Transform**: apply transformation to each item. A **transformer** may generate 0, 1 or several items to **load** (for example, 1 item may generate multiple SQL queries)
- **Load**: load transformed item to the destination. For example, **extracted items** have been **transformed** to SQL queries, and your **loader** will run those queries against your database.

Installation
------------

[](#installation)

```
composer require bentools/etl
```

Warning

Current version (4.0) is a complete redesign and introduces significant BC (backward compatibility) breaks. Avoid upgrading from `^2.0` or `^3.0` unless you're fully aware of the changes.

Usage
-----

[](#usage)

Now let's have a look on how simple it is:

```
use BenTools\ETL\EtlExecutor;

// Given
$singers = ['Bob Marley', 'Amy Winehouse'];

// Transform each singer's name to uppercase and process the array
$etl = (new EtlExecutor())
    ->transformWith(fn (string $name) => strtoupper($name));

// When
$report = $etl->process($singers);

// Then
var_dump($report->output); // ["BOB MARLEY", "AMY WINEHOUSE"]
```

OK, that wasn't really hard, here we basically don't have to *extract* anything (we can already iterate on `$singers`), and we're not *loading* anywhere, except into PHP's memory.

You may ask, "why don't you just `array_map('strtoupper', $singers)` ?" and you're totally right.

But sometimes, extracting, transforming and / or loading get a little more complex. You may want to extract from a file, a crawled content on the web, perform one to many transformations, maybe skip some items, or reuse some extraction, transformation or loading logic.

Here's another example of what you can do:

```
use BenTools\ETL\EventDispatcher\Event\TransformEvent;
use BenTools\ETL\Loader\JSONLoader;

use function BenTools\ETL\extractFrom;

$executor = extractFrom(function () {
    yield ['firstName' => 'Barack', 'lastName' => 'Obama'];
    yield ['firstName' => 'Donald', 'lastName' => 'Trump'];
    yield ['firstName' => 'Joe', 'lastName' => 'Biden'];
})
    ->transformWith(fn (array $item) => implode(' ', array_values($item)))
    ->loadInto(new JSONLoader())
    ->onTransform(function (TransformEvent $event) {
        if ('Donald Trump' === $event->transformResult->value) {
            $event->state->skip();
        }
    });

$report = $executor->process();

dump($report->output); // string '["Barack Obama", "Joe Biden"]'
```

Or:

```
$report = $executor->process(destination: 'file:///tmp/presidents.json');
var_dump($report->output); // string 'file:///tmp/presidents.json' - content has been written here
```

You get the point. Now you're up to write your own workflows!

Continue reading the [Getting Started Guide](doc/getting-started.md).

Contribute
----------

[](#contribute)

Contributions are welcome! Don't hesitate to suggest recipes.

This library is 100% covered with [Pest](https://pestphp.com) tests.

Please ensure to run tests using the command below and maintain code coverage before submitting PRs.

```
composer ci:check
```

License
-------

[](#license)

MIT.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~96 days

Recently: every ~199 days

Total

39

Last Release

97d ago

Major Versions

v1.1.0 → v2.02017-02-27

2.5.x-dev → 3.0-alpha2019-04-04

3.0-alpha.3 → 4.0-alpha12023-10-26

PHP version history (4 changes)v1.0.0PHP &gt;=5.4

v2.0PHP &gt;=7.1

3.0-alphaPHP &gt;=7.2

4.0-alpha1PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/acdd1a8ee0e657ddd06cf11f98a32100ef7121afb8aa270a5b295f5c29c038b3?d=identicon)[bpolaszek](/maintainers/bpolaszek)

---

Top Contributors

[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (133 commits)")[![ben-synapse](https://avatars.githubusercontent.com/u/36077477?v=4)](https://github.com/ben-synapse "ben-synapse (18 commits)")[![nclavaud](https://avatars.githubusercontent.com/u/1181770?v=4)](https://github.com/nclavaud "nclavaud (1 commits)")

---

Tags

callableetlexportextractextractorimportinputinvokeloadloaderloopoutputpatternphptransformtransformer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bentools-etl/health.svg)

```
[![Health](https://phpackages.com/badges/bentools-etl/health.svg)](https://phpackages.com/packages/bentools-etl)
```

###  Alternatives

[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[windwalker/framework

The next generation PHP framework.

25639.1k1](/packages/windwalker-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
