plumphp/plum
Plum is a PHP data processing pipeline for building reusable, testable workflows. Chain readers, filters, converters, and writers, apply conditional conversions, concatenate workflows, and merge multiple sources to transform and export data cleanly and flexibly.
Plum is a lightweight, PSR-4-compatible data processing pipeline library for PHP. To begin:
composer require plumphp/plumPlum\Plum class — chain Readers (data sources), Processors (transformations), and Writers (destinations)use Plum\Plum\Plum;
use Plum\Plum\Reader\CSVReader;
use Plum\Plum\Processor\CallbackProcessor;
use Plum\Plum\Writer\JSONWriter;
$plum = new Plum();
$plum->readFrom(new CSVReader('input.csv'))
->processWith(new CallbackProcessor(function ($row) {
$row['name'] = strtoupper($row['name'] ?? '');
return $row;
}))
->writeTo(new JSONWriter('output.json'));
$plum->run();
Start with the README — despite low activity, the API is stable and simple.
UpperNameProcessor) for clarity and testabilityBatchProcessor to handle array inputs efficiently, e.g., bulk sanitizationConditionalProcessor (e.g., skip validation for test data)ErrorLoggingProcessor to capture and log bad rowsCallbackReader with generators for memory-efficient large-file handlingStorage facade — extend Writer/Reader to read/write from s3:// or local:// disksspl_autoload_register or use a bridge like composer-classmap-generator if needed)JSONWriter loads entire dataset into memory — for large files, use NDJSONWriter (line-delimited JSON) insteadReaderInterface, ProcessorInterface, or WriterInterface — all have minimal contractsDebugProcessor to dump rows mid-pipeline:->processWith(new CallbackProcessor(function ($row) {
// ...
}), new DebugProcessor()) // dumps each row to stderr
— but remember to remove before production.
How can I help you explore Laravel packages today?