New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

chipslays/collection

Laravel-compatible PHP collection with dot-notation and wildcard paths in every method. Zero dependencies.
1,200 1
Install
composer require chipslays/collection
Latest Version:1.0.0
PHP:^8.4
License:MIT
Last Updated:Oct 7, 2026
Links: GitHub  ·  Packagist
Maintainer: chipslays

Collection 📁

Laravel-style collections for any PHP project — with dot-notation paths in every method.

Latest version Tests PHP version Downloads License


Why Collection

  • Paths everywhere. get, set, where, sortBy, groupBy, sum, pluck and dozens of other methods accept paths like user.address.city, users.*.email, users[?active].email or **.email. Paths go through arrays, objects and nested collections — and stay close to hand-written loops in speed.
  • Reshape data in one call. rename() and remap() move fields into the structure you need; cast() converts types with built-in casters, enums, classes, callbacks or your own Caster.
  • The Laravel API you already know. Every method of Illuminate\Support\Collection, with the same names and behaviour — but no framework required. What is different 🤔
  • You stay in control. Methods that wrap PHP functions expose their options: SORT_* flags, JSON flags and depth, preserveKeys, a seeded Random\Randomizer, rounding modes.
  • No surprises. Transforming methods return a new collection; the few that change data in place are clearly listed. Strings are never called as functions by accident.
  • Zero dependencies. PHP 8.4+, one package, fully tested and statically analysed.

Installation

composer require collection/collection
use Collection\Collection;

$c = new Collection($array);
$c = Collection::make($arrayOrJsonOrIterable);
$c = collection($array); // global helper

Documentation

Section Description
Getting Started creating collections, conventions, exceptions, subclassing
Paths: Dot-Notation & Wildcards user.name, users.*.email, users.*[id], users[?age>18], **.email, objects, escaping dots
Reading, Writing & Converting get, set, has, forget, push, toJson…
Filtering & Finding where, filter, first, sole, contains, unique…
Transforming map, pluck, mapPath, flatten, toTree, reduce…
Reshaping: rename, remap & cast rename/move keys, build new structures, convert types
Sorting & Grouping sortBy, groupBy, keyBy, countBy, partition
Aggregates sum, avg, median, mode, percentage…
Slicing, Chunking & Randomness slice, chunk, paginate, sliding, random…
Combining Collections merge, diff, intersect, zip, crossJoin…
Pipelines, Macros & Debugging pipe, when, higher-order messages, macros, dump
Coming from Laravel what is the same and what is different

All methods at a glance 👉


Contributing

composer test # Pest
composer analyse # PHPStan

Issues and pull requests are welcome!

License

MIT — see LICENSE.md.

Related Packages

collector/collector

A collection library inspired by Laravel Collections, built using generators to...

208 15
iteks/laravel-json

A Laravel package for simplified JSON data manipulation, offering seamless conve...

24,163 4
aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar...

521,124 4,326
mb4it/collections

Separate collections Illuminate\Support\Collections

394 0
pragmarx/ia-arr

Laravel Illuminate Agnostic Arr

3,778,217 55

Version History

Version Released License
1.0.0 MIT