Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Plum Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Plum is a lightweight, PSR-4-compatible data processing pipeline library for PHP. To begin:

  • Install via Composer: composer require plumphp/plum
  • Define a pipeline using Plum\Plum class — chain Readers (data sources), Processors (transformations), and Writers (destinations)
  • First use case: read CSV → transform rows (e.g., filter uppercase fields) → write to JSON
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.

Implementation Patterns

  • Modular Pipelines: Compose processors into reusable classes (e.g., UpperNameProcessor) for clarity and testability
  • Batch Processing: Use BatchProcessor to handle array inputs efficiently, e.g., bulk sanitization
  • Conditional Logic: Chain processors conditionally using ConditionalProcessor (e.g., skip validation for test data)
  • Error Handling: Wrap writers/processors in ErrorLoggingProcessor to capture and log bad rows
  • Lazy Streams: Prefer CallbackReader with generators for memory-efficient large-file handling
  • Integration Tip: Pair with Laravel’s Storage facade — extend Writer/Reader to read/write from s3:// or local:// disks

Gotchas and Tips

  • No Active Maintenance: As of 2015, no updates — verify compatibility with PHP 8+ (works via PSR-0 autoloading in older versions; add spl_autoload_register or use a bridge like composer-classmap-generator if needed)
  • Processor Signatures: Processors must return the modified row (or null to skip) — forgetting to return causes silent data loss
  • Memory Pitfall: JSONWriter loads entire dataset into memory — for large files, use NDJSONWriter (line-delimited JSON) instead
  • Testing: Unit-test processors in isolation — they’re pure functions — and mock readers/writers in pipeline tests
  • Extension Points: Implement custom ReaderInterface, ProcessorInterface, or WriterInterface — all have minimal contracts
  • Debugging: Use DebugProcessor to dump rows mid-pipeline:
->processWith(new CallbackProcessor(function ($row) {
    // ...
}), new DebugProcessor()) // dumps each row to stderr  

— but remember to remove before production.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport