xi/collections
xi/collections extends Laravel Collections with handy, chainable macros and helpers for cleaner, more expressive array and data manipulation. Lightweight and easy to drop into any Laravel or PHP project.
Enum and immutable collection types, which is exactly the toolkit for deciding whether a status column should be a string, an int constant, or a typed enumeration — and whether a lines relationship should be an array, a mutable Collection, or an immutable value object.enum (8.1+), readonly properties (8.1+), and array_is_list/first-class callable syntax.My call: the category (immutable enumerations and collections) scores well on opportunity; this implementation does not. Treat it as a design reference, not a dependency.
Consider it only if:
NOASSERTION, so legal must confirm terms before any install).Look elsewhere if any of the following is true — and for most teams at least three will be:
strict_types.enum plus readonly classes covers the enumeration use case with zero dependencies and full static analysis support.ramsey/collection, marcosh/php-collections, yiisoft/collections, Doctrine Collections (if already in the stack), or Laravel's Illuminate\Support\Collection for the mutable/fluent case.If your answer is "we're on PHP 8 and we want immutable domain collections," the honest recommendation is: adopt the pattern, choose a maintained library or a 40-line internal base class, and move on.
To executives (one paragraph): This package solves a real modeling problem — making enumerations and collections type-safe and impossible to mutate accidentally — and the category is worth investing in. This particular library, however, is a legacy artifact: it targets PHP 5.3 (end-of-life since 2014), has no dependents, no visible maintenance, and an unresolved license. I recommend a time-boxed spike (1–2 days) to borrow its interface design, then standardize on PHP 8.1 native enums plus a maintained collection library. Cost of the spike is trivial; cost of adopting the dependency is unbounded upgrade and legal risk.
To engineering (the ask):
xi/collections to composer.json.ramsey/collection) behind an interface you own, so the choice is reversible.phpstan/psalm) rules that flag mutable arrays crossing domain boundaries — that is the real, durable version of what this package was reaching for in 2012.Framing line for the roadmap review: "Low-cost, low-risk to study; high-risk to depend on. We take the pattern, not the package."
How can I help you explore Laravel packages today?