PHPackages                             bnomei/kirby3-collect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bnomei/kirby3-collect

AbandonedArchivedKirby-plugin[Utility &amp; Helpers](/categories/utility)

bnomei/kirby3-collect
=====================

Adds support for Laravel collections to Kirby

1.1.0(2y ago)3317MITPHPPHP &gt;=8.0.0

Since May 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bnomei/kirby3-collect)[ Packagist](https://packagist.org/packages/bnomei/kirby3-collect)[ RSS](/packages/bnomei-kirby3-collect/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Kirby Collect
=============

[](#kirby-collect)

[![Release](https://camo.githubusercontent.com/996804b74409b76458711af4eda4bad2b92322df4161168a64c5428cbed951eb/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d636f6c6c6563743f636f6c6f723d616538316666)](https://camo.githubusercontent.com/996804b74409b76458711af4eda4bad2b92322df4161168a64c5428cbed951eb/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d636f6c6c6563743f636f6c6f723d616538316666)[![Downloads](https://camo.githubusercontent.com/2eb22fc1864bf01e812deb31292b64e35136ca210a52ae484e196183cb49cca0/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d636f6c6c6563743f636f6c6f723d323732383232)](https://camo.githubusercontent.com/2eb22fc1864bf01e812deb31292b64e35136ca210a52ae484e196183cb49cca0/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d636f6c6c6563743f636f6c6f723d323732383232)[![Build Status](https://camo.githubusercontent.com/fc189ac80723e70deaea5e5af03025bd59b710abe4f8b1f3761616f49ec1cc49/68747470733a2f2f666c61742e62616467656e2e6e65742f7472617669732f626e6f6d65692f6b69726279332d636f6c6c656374)](https://travis-ci.com/bnomei/kirby3-collect)[![Coverage Status](https://camo.githubusercontent.com/3a43aa62781ca151de3a561d9ea195a44f5ae487f829b9c6cb1ed3a3b4986731/68747470733a2f2f666c61742e62616467656e2e6e65742f636f766572616c6c732f632f6769746875622f626e6f6d65692f6b69726279332d636f6c6c656374)](https://coveralls.io/github/bnomei/kirby3-collect)[![Maintainability](https://camo.githubusercontent.com/c7b063e5c1dcab4059d3a57218ab4bdc2301e8728bb05fc582b18bb51c8871f4/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f626e6f6d65692f6b69726279332d636f6c6c656374)](https://codeclimate.com/github/bnomei/kirby3-collect)[![Twitter](https://camo.githubusercontent.com/b90e4b58a887e8ad09ec267628b75199a48522a9e01e88b129e5d2d730dffe50/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f747769747465722f626e6f6d65693f636f6c6f723d363664396566)](https://twitter.com/bnomei)

Adds support for Laravel collections to Kirby

Installation
------------

[](#installation)

- unzip [master.zip](https://github.com/bnomei/kirby3-collect/archive/master.zip) as folder `site/plugins/kirby3-collect` or
- `git submodule add https://github.com/bnomei/kirby3-collect.git site/plugins/kirby3-collect` or
- `composer require bnomei/kirby3-collect`

Why Laravel collections?
------------------------

[](#why-laravel-collections)

This is a plugin for those that create web-projects in Kirby that have to manipulate lots of array data and want to [refactor to collections](https://adamwathan.me/refactoring-to-collections/) to avoid excessive use of `foreach`-loops and `if`-clauses.

Usage
-----

[](#usage)

See official Laravel docs on how to use the [collect](https://laravel.com/docs/9.x/collections)-helper and the collection methods.

all, average, avg, **chunk**, chunkWhile, collapse, collect, combine, concat, contains, containsStrict, **count**, countBy, crossJoin, dd, diff, diffAssoc, diffKeys, doesntContain, dump duplicates, duplicatesStrict, each, eachSpread, every, except, filter, **first**, firstOrFail, firstWhere, flatMap, flatten, **flip**, forget, forPage, **get**, **groupBy**, **has**, implode, intersect, intersectByKeys, **isEmpty**, isNotEmpty, join, keyBy, keys, last, lazy, macro, make, **map**, mapInto, mapSpread, mapToGroups, mapWithKeys, max, median, merge, mergeRecursive, min, mode, **nth**, only, pad, partition, pipe, pipeInto, pipeThrough, **pluck**, pop, **prepend**, pull, push, put, **random**, range, reduce, reduceSpread, reject, replace, replaceRecursive, reverse **search**, shift, **shuffle**, sliding, skip, skipUntil, skipWhile, **slice**, sole, some, **sort**, **sortBy**, sortByDesc, sortDesc, sortKeys, sortKeysDesc, sortKeysUsing, splice, split, splitIn, sum, take, takeUntil, takeWhile, tap, times, **toArray**, **toJson**, transform, undot, union, unique, uniqueStrict, unless, unlessEmpty, unlessNotEmpty, unwrap, **values**, **when**, whenEmpty, whenNotEmpty, where, whereStrict, whereBetween, whereIn, whereInStrict, whereInstanceOf, whereNotBetween, whereNotIn, whereNotInStrict, whereNotNull, whereNull, wrap, zip

The methodnames in bold indicate that Kirby has a similar collection method. It also features to [some additional methods](https://getkirby.com/docs/reference/objects/cms/collection).

### Laravel collections from an array

[](#laravel-collections-from-an-array)

You can also get a laravel collection object from any array.

```
$laravelCollection = collect($array);
```

### Create a Laravel collection from a Kirby collection

[](#create-a-laravel-collection-from-a-kirby-collection)

```
// retrieve a kirby collection
$kirbyCollection = site()->index()->children();

// get a laravel collection object from a kirby collection
$laravelCollection = $kirbyCollection->collect();
$laravelCollection = $kirbyCollection->_();
```

### Primitive data-types only

[](#primitive-data-types-only)

You can also convert all objects into primitive types using json encoding and decoding. But be warned that most of Kirby's core objects will not ([yet](https://kirby.nolt.io/431)) automatically serialize themselves.

```
$laravelCollection = $kirbyCollection->collect(true);
$laravelCollection = $kirbyCollection->_(true);
```

### When to use Laravel collection methods (and when not)

[](#when-to-use-laravel-collection-methods-and-when-not)

To achieve certain common use-cases the Laravel collections methods are a bit more explicit than Kirby's collection methods.

```
$mostPopularPage = $kirbyCollection
    ->sortBy('viewcount')
    ->last()
    ->viewcount()
    ->toInt();

$mostPopularPage = $kirbyCollection
    ->collect()
    ->max('content.viewcount');
```

```
$hasProductWithBookcase = $kirbyCollection
    ->filterBy('product', '==', 'Bookcase')
    ->count() > 0;

$hasProductWithBookcase = $kirbyCollection
    ->collect()
    ->contains('content.product', 'Bookcase');
```

But keep in mind that Kirby's collection methods have been tailored to work with the core objects like `Page` and make some tasks very easy where using Laravel collection methods would be more tedious.

```
$allTags = $kirbyCollection
    ->pluck('tags', ', ', true);

$allTags = $kirbyCollection
    ->collect()
    ->pluck('content.tags')
    ->flatMap(fn($item) => explode(', ', $item))
    ->unique();
```

### Underscore shorthand

[](#underscore-shorthand)

Instead of calling the `->collect()`/`_()` collection method evert time you can also use underscore to **start** with laravel collections object. But any further method calls do not need the `_` prefix.

```
$mostPopularPage = $kirbyCollection
    ->_max('content.viewcount');

$hasProductWithBookcase = $kirbyCollection
    ->_contains('content.product', 'Bookcase');

$allTags = $kirbyCollection
    ->_pluck('content.tags')
    ->flatMap(fn($item) => explode(', ', $item))
    ->unique();
```

Dependencies
------------

[](#dependencies)

- [illuminate/collections](https://github.com/illuminate/collections)

Disclaimer
----------

[](#disclaimer)

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-collect/issues/new).

License
-------

[](#license)

[MIT](https://opensource.org/licenses/MIT)

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~476 days

Total

2

Last Release

981d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3265642?v=4)[Bruno Meilick](/maintainers/bnomei)[@bnomei](https://github.com/bnomei)

---

Top Contributors

[![bnomei](https://avatars.githubusercontent.com/u/3265642?v=4)](https://github.com/bnomei "bnomei (8 commits)")

---

Tags

arraycollectcollectioncollectionskirby3kirby3-cmskirby3-pluginlaravelmethodslaravelcollectioncollectmethodskirby3kirby3-pluginkirby3-cms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bnomei-kirby3-collect/health.svg)

```
[![Health](https://phpackages.com/badges/bnomei-kirby3-collect/health.svg)](https://phpackages.com/packages/bnomei-kirby3-collect)
```

###  Alternatives

[fabianmichael/kirby-meta

Your all-in-one powerhouse for any SEO and metadata needs imaginable.

6910.7k1](/packages/fabianmichael-kirby-meta)[cerbero/lazy-json

Framework-agnostic package to load JSONs of any dimension and from any source into Laravel lazy collections.

254309.8k1](/packages/cerbero-lazy-json)[gamez/typed-collection

Type-safe collections based on Laravel Collections

45317.8k](/packages/gamez-typed-collection)[bvdputte/kirby-fingerprint

Cache-busting utility to fingerprint assets (JS/CSS) in Kirby 3

1610.0k](/packages/bvdputte-kirby-fingerprint)[dutchcodingcompany/csv-collection

Read and write large csv files using Laravel's Illuminate Collections

117.5k](/packages/dutchcodingcompany-csv-collection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
