Skip to content

Latest commit

 

History

History
96 lines (71 loc) · 3.07 KB

index.md

File metadata and controls

96 lines (71 loc) · 3.07 KB

Plum

Plum is a data processing pipeline that helps you to write structured, reusable and well tested data processing code.

Developed by Florian Eckerstorfer in Vienna, Europe.

Features

Plum is a data processing pipeline, that means it reads data, filters and converts it and then writes the data.

  • Plum provides you with readers and writers for common data formats as well as converters and filters that are frequently required in data processing tasks.
  • Filters, converters and even writers are pipeline elements that can be attached to a workflow in arbitrary order
  • Readers are iterators that can return values of arbitrary type: arrays, objects or scalars, it doesn't matter to Plum
  • Conditional converters that are only applied to an item if it passes a filter
  • Ability to concatenate workflow to create smaller and better reusable workflows
  • Read from multiple sources, i.e., merge data from different sources into an output
  • By providing you with clean interfaces and a strong separation of concern your data processing code will be more structured, better reusable and well tested.
  • Plums power comes from its extendability, check out additional packages and integrations

Plum has been greatly inspired by ddeboer/data-import.

Installation

You can install Plum using Composer (recommended) or by downloading a release.

$ composer require plumphp/plum

Workflow

Plum provides you with a Workflow class and you can attach filters, converters and writers to it and process it using one or multiple readers. A workflow can be processed one time or multiple times.

use Plum\Plum\Workflow;

$workflow = new Workflow();
$workflow->addFilter($filter)
         ->addConverter($converter)
         ->addWriter($writer);
$result = $workflow->process($reader);

Example

To give you a quick example of the power of Plum here is a simple CSV to Excel converter.

use Plum\Plum\Workflow;
use Plum\Plum\Converter\HeaderConverter;
use Plum\Plum\Filter\SkipFirstFilter;
use Plum\PlumCsv\CsvReader;
use Plum\PlumExcel\ExcelWriter;

$workflow = new Workflow();
$workflow->addConverter(new HeaderConverter())
         ->addFilter(new SkipFirstFilter(1))
         ->addWriter((new ExcelWriter('output/countries.xlsx'))->autoDetectHeader());
$result = $workflow->process(new CsvReader('input/countries.csv'));

Table of Contents

  1. Workflow
  2. Readers
  3. Writers
  4. Filters
  5. Converters
  6. Extensions

Index Workflow Readers Writers Filters Converters Extensions