flow php

UNIFIED DATA PROCESSING FRAMEWORK

composer require flow-php/etl ~0.34.3

ChangelogRelease Cycle

play Try Playground

elephant
extract

Extracts

Read from various data sources.

arrow
transform

Transforms

Shape and optimize for your needs.

arrow
load

Loads

Store and secure in one of many available data sinks.

Examples:

Description

Combine two datasets based on matching column values, similar to SQL JOIN operations. Supports inner, left, right, and left anti join types.

For large datasets that don't fit in memory, consider using joinEach instead.

Documentation

Code

play
<?php

declare(strict_types=1);

use function Flow\ETL\DSL\{data_frame, from_array, join_on, to_output};
use Flow\ETL\Join\Join;

require __DIR__ . '/vendor/autoload.php';

$users = [
    ['id' => 1, 'name' => 'John'],
    ['id' => 2, 'name' => 'Jane'],
    ['id' => 3, 'name' => 'Doe'],
    ['id' => 4, 'name' => 'Bruno'],
];

$emails = [
    ['id' => 2, 'email' => '[email protected]'],
    ['id' => 3, 'email' => '[email protected]'],
    ['id' => 4, 'email' => '[email protected]'],
];

data_frame()
    ->read(from_array($users))
    ->join(
        data_frame()->read(from_array($emails)),
        join_on(['id' => 'id'], join_prefix: 'joined_'),
        Join::left
    )
    ->collect()
    ->write(to_output(truncate: false))
    ->run();

Contributors

Join us on GitHub external resource
scroll back to top