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.
To add the library to your project, run the following Composer command:
composer require sanmai/pipeline
It is recommended to use a version constraint to ensure your project remains compatible with future releases.
Latest Stable Version (Recommended)
{
"require": {
"sanmai/pipeline": "^7.0"
}
}
Development Version
To use the latest development version, you can require the dev-main branch:
composer require sanmai/pipeline:dev-main
The library follows the PSR-4 autoloading standard. Ensure you include Composer's autoloader in your project's entry point:
require_once 'vendor/autoload.php';
To confirm the library is installed correctly, you can run this simple script:
<?php
require_once 'vendor/autoload.php';
use function Pipeline\take;
$result = take([1, 2, 3, 4, 5])
->map(fn($x) => $x * 2)
->toList();
print_r($result); // Expected output: [2, 4, 6, 8, 10]
The library provides helper functions in the Pipeline namespace. You can import them individually or use their fully qualified names.
// Import individual functions
use function Pipeline\take;
use function Pipeline\map;
// Or use fully qualified names
$pipeline = \Pipeline\take($data);
For direct class usage, import the necessary classes:
use Pipeline\Standard;
$pipeline = new Standard($data);
If you plan to contribute to the library or run its test suite, follow these steps:
Clone the repository:
git clone https://github.com/sanmai/pipeline.git
cd pipeline
Install dependencies (including dev-dependencies):
composer install
Run the test suite:
make test
To run static analysis tools like PHPStan and Psalm, first ensure they are installed, then run the analysis command:
composer require --dev phpstan/phpstan vimeo/psalm
make analyze
Memory Limit Issues: If Composer fails due to memory limits, you can run it with an unlimited memory setting:
COMPOSER_MEMORY_LIMIT=-1 composer require sanmai/pipeline
Platform Requirements: Ensure your environment meets the minimum PHP version requirement:
php -v // Must be 8.2.0 or higher
Composer Version: If you encounter issues, ensure Composer is up-to-date:
composer self-update
How can I help you explore Laravel packages today?