- What is sanmai/pipeline and how does it fit into Laravel applications?
- sanmai/pipeline is a Composer package for building fluent, lazy pipelines in PHP. It lets you chain operations like map, filter, reduce, and zip over arrays, generators, or any iterable. In Laravel it fits naturally in service classes, command handlers, and queued jobs for sequential data processing without coupling to the framework.
- How do I install sanmai/pipeline with Composer?
- Run composer require sanmai/pipeline in your Laravel project. The latest release requires PHP 8.2 or above, so confirm your runtime before installing. No Laravel service provider or additional configuration is required.
- Does sanmai/pipeline support Laravel and which PHP versions are supported?
- The package is framework-agnostic and works in Laravel because it is a standard Composer package. The latest version requires PHP 8.2 or higher; some older releases support PHP 5.6 and above but are less feature-complete. Check the package composer.json against your application runtime before rollout.
- How does sanmai/pipeline handle large or infinite collections without exhausting memory?
- It uses lazy evaluation with generators, so items are processed one by one only when needed. That makes it suitable for large or even infinite iterables where eager array operations would consume too much memory. You can chain map, filter, and other stages without materializing the entire collection.
- What is the difference between sanmai/pipeline and Laravel collections?
- Laravel Collections are eager, array-backed helpers with a broad Laravel-specific API. sanmai/pipeline focuses on lazy, memory-efficient processing of any iterable, including generators, with a fluent pipe-style API. Choose it when streaming, large datasets, or non-HTTP domain logic matter more than Collection macros.
- How do I chain map, filter, reduce, and zip in sanmai/pipeline?
- Wrap your iterable with the take helper, then chain stages such as map, filter, reduce, and zip. The pipeline evaluates lazily, so transformations run as items flow through. You can also zip multiple iterables side by side without converting them to arrays first.
- Does sanmai/pipeline throw exceptions or require error handling?
- No, the library neither defines nor throws any exceptions, which keeps pipeline code predictable. Errors from your own callbacks can still occur, so handle application-specific failures in your stages. The package itself avoids exception-based control flow.
- What changed in sanmai/pipeline 7.12 regarding skipWhile?
- Release 7.12 fixes skipWhile so predicate evaluation stops once a match is found. This is a behavioral bug fix with no new public API and no required code changes. Review any pipeline that relied on the predicate continuing to run after a match, especially with side-effectful predicates.
- Should I pin sanmai/pipeline to ^7.12 and add a skipWhile regression test?
- Pinning to ^7.12 is reasonable because the release is a backward-compatible patch within 7.x. Add a regression test if your production pipelines use skipWhile, particularly with expensive or side-effectful predicates. This verifies the new short-circuit behavior before promotion.
- Is sanmai/pipeline safe for production and queued jobs in Laravel?
- Technical risk for 7.12 is low: it contains one behavioral fix plus documentation and chore updates, with no breaking changes or deprecations. It integrates cleanly into Laravel service classes and queued jobs with a trivial Composer install. Upgrade in non-production first, run your test suite, and then promote through your normal release process.