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

Pipeline Laravel Package

sanmai/pipeline

sanmai/pipeline is a lightweight PHP pipeline library to process data through a chain of stages. Compose reusable, testable transformations with clear input/output flow, and plug in custom middleware-like steps for flexible processing in any app.

View on GitHub
Deep Wiki
Context7

Helper Functions

Helper functions provide a convenient, fluent syntax for creating pipeline instances.

map()

Creates a pipeline from a generator function or a single value.

Signature: map(?callable $func = null): Standard

  • $func: An optional generator function.

Behavior:

  • If $func is a generator, the pipeline is populated with the yielded values.
  • If $func returns a single value, the pipeline will contain that one element.
  • If no function is provided, an empty pipeline is created.

Examples:

use function Pipeline\map;

// From a generator
$pipeline = map(function () {
    for ($i = 1; $i <= 3; $i++) {
        yield $i;
    }
});

// From a single value
$pipeline = map(fn() => 'Hello'); // Contains ['Hello']

take()

Creates a pipeline from one or more iterables.

Signature: take(?iterable $input = null, iterable ...$inputs): Standard

  • $input: The primary data source.
  • ...$inputs: Additional data sources to append.

Examples:

use function Pipeline\take;

// From a single array
$pipeline = take([1, 2, 3]);

// From multiple sources
$pipeline = take([1, 2], new ArrayIterator([3, 4]));

fromArray()

Creates a pipeline from an array, offering better type safety if you specifically need to handle an array.

Signature: fromArray(array $input): Standard

Examples:

use function Pipeline\fromArray;

$pipeline = fromArray(['a' => 1, 'b' => 2]);

fromValues()

Creates a pipeline from a sequence of individual values.

Signature: fromValues(...$values): Standard

Examples:

use function Pipeline\fromValues;

$pipeline = fromValues(1, 'a', true);

zip()

Combines multiple iterables into a single pipeline of tuples.

Signature: zip(iterable $base, iterable ...$inputs): Standard

Behavior:

  • Creates a new pipeline where each element is an array of corresponding elements from the input iterables.
  • Shorter iterables are padded with null.

Examples:

use function Pipeline\zip;

$names = ['Alice', 'Bob'];
$ages = [30, 25];

$result = zip($names, $ages)->toList();
// [['Alice', 30], ['Bob', 25]]
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
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
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests