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.
Architecture fit
xi/collections targets functional, immutable enumerations and collections (maps, sets, lists, vectors) with a Scala-inspired API (map/filter/fold, Function1-style callables). It is a domain-layer abstraction, not an infrastructure one.Illuminate\Support\Collection — mutable, array-backed, fluent, and tightly coupled to the framework's helpers. xi/collections occupies the same slot with opposite semantics (persistence-agnostic, immutable, strongly interface-driven). The two are not designed to compose.illuminate/support.strict_types, no generators — the library predates every type-safety idiom a modern Laravel codebase relies on. Static analysis (PHPStan/Larastan) will see almost entirely untyped surfaces.Integration feasibility
composer.json that predates Composer 2 conventions; autoload rules may need to be overridden. Verify the package even resolves against a modern platform config.Illuminate\Support\Collection ↔ Xi\Collections types), register implementations behind your own interfaces, and never let Xi\* types leak into controllers, resources, or Eloquent models.CastsAttributes implementations yourself.Technical risk
LICENSE/file headers before adoption — and may still fail policy.enum became a soft reserved word in PHP 8.1, and the package exposes an Enum type — confirm the parser and your import statements behave; also confirm no reliance on each(), create_function, or other removed PHP 8 constructs.enum and Illuminate\Support\Collection is high for onboarding engineers.Key questions
readonly classes + native enum + Illuminate\Support\Collection express the same domain model with zero dependency risk?Stack fit
readonly classes and native enums; (b) vendor/fork — copy into app/Domain/Support, pin the license, own the maintenance; (c) direct dependency — only if legal clears the license and you accept perpetual pinning.Migration path
illuminate/support in the same layer. Choose one representation per bounded context.Domain\Collection interfaces first, then implement them with either backend. This lets you swap the implementation later without touching call sites.CollectionFactory/adapter service, bind via a service provider, and enforce boundary conversion in a single mapper class. Add an architecture test (e.g., PHPArkitect/deptrac) that forbids Xi\ outside the adapter namespace.Compatibility
composer dump-autoload -o --classmap-authoritative) — this is a common silent failure for old packages.serialize(), json_encode(), and Laravel's queue payloads before committing.Sequencing
Maintenance
Support
Scaling
Failure modes
Xi\ types in controllers/resources) → frozen architecture that is expensive to unwind.Ramp-up
collect().readonly and enum. That captures the 6.74 opportunity while eliminating the 0.29 artifact.How can I help you explore Laravel packages today?