PHPackages                             lordmonoxide/collection - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. lordmonoxide/collection

ActiveLibrary[File &amp; Storage](/categories/file-storage)

lordmonoxide/collection
=======================

Powerful but easy to use collections with support for lazy loading

1.0.0(10y ago)0171GPLv3PHPPHP &gt;=5.4.0

Since May 23Pushed 10y ago1 watchersCompare

[ Source](https://github.com/LordMonoxide/collection)[ Packagist](https://packagist.org/packages/lordmonoxide/collection)[ Docs](http://github.com/LordMonoxide/collection)[ RSS](/packages/lordmonoxide-collection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/fb6046c2c4c0471be2c9d463cdff4babd073b2d99fa039faa0f371d66e960e9b/68747470733a2f2f7472617669732d63692e6f72672f4c6f72644d6f6e6f786964652f636f6c6c656374696f6e2e7376673f6272616e63683d312e302e30)](https://travis-ci.org/LordMonoxide/collection)[![Coverage Status](https://camo.githubusercontent.com/215ab5e459bfad74922392fc02c5ef5f950b49f379e736fed596d14e62ab395b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4c6f72644d6f6e6f786964652f636f6c6c656374696f6e2f62616467652e7376673f6272616e63683d312e302e30)](https://coveralls.io/r/LordMonoxide/collection?branch=1.0.0)[![License](https://camo.githubusercontent.com/d195dc3a1db6593ad63e90c1487ceed40119653fb8d203d07dd583e1f4ac52fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f4c6f72644d6f6e6f786964652f636f6c6c656374696f6e2e737667)](https://img.shields.io/packagist/l/LordMonoxide/collection.svg)

Collection
==========

[](#collection)

A modular, trait-based collection library that puts control of your data back in your hands.

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

[](#installation)

### Composer

[](#composer)

[Composer](https://getcomposer.org/) is the recommended method of installation for Collection.

```
$ composer require lordmonoxide/collection

```

### GitHub

[](#github)

Phi may be downloaded from [GitHub](https://github.com/LordMonoxide/collection/).

Features
--------

[](#features)

### Basic Collection Use

[](#basic-collection-use)

Collections make it easy to control access to your data in an object-oriented way. The standard implementation supports reading and writing, as well as standard `foreach` iteration.

```
$collection = new Collection(['k1' => 'v1']);

var_dump($collection->get('k1')); // 'v1'
var_dump($collection->size()); // 1

$collection->set('k2', 'v2');

$collection->add('v3');

// $collection == ['k1' => 'v1', 'k2' => 'v2', 'v3']

$collection->remove('k2');

// $collection == ['k1' => 'v1', 'v3']

foreach($collection as $k => $v) {
    //
}
```

### Custom Collections

[](#custom-collections)

Collections are built with traits, so it's easy to pick-and-choose the features you want. For example, you may want a collection that can't be modified from the outside:

```
class MyCollection implements ReadableCollectionInterface {
    use ReadableCollectionTrait;

    protected $collection = [];
}
```

If you would like to implement a full read/write collection, you may extend the basic `Collection` class:

```
class MyCollection extends Collection {
    //
}
```

Or, you may implement the interfaces and trait:

```
class MyCollection implements ReadableCollectionInterface, WritableCollectionInterface {
    use ReadableCollectionTrait, WritableCollectionTrait;
}
```

### Array Access

[](#array-access)

If you would like to use array access with your collection, use the `ArrayAccessCollection` class or the `ArrayAccessCollectionTrait` trait.

### Lazy Loading

[](#lazy-loading)

Writable collections have support for lazy-loading built in. Lazy loading can be very useful, for example, in database interactions.

```
$collection->lazy(1, function($key) {
    return User::find($key);
});
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4014d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/246ea082e8ed7f6e8ace29950179d4dfb1e3a58bac53aef49a3d2e43ab1e7f04?d=identicon)[LordMonoxide](/maintainers/LordMonoxide)

---

Top Contributors

[![LordMonoxide](https://avatars.githubusercontent.com/u/437657?v=4)](https://github.com/LordMonoxide "LordMonoxide (10 commits)")

---

Tags

arraystoragecollectionlazyRead only

### Embed Badge

![Health badge](/badges/lordmonoxide-collection/health.svg)

```
[![Health](https://phpackages.com/badges/lordmonoxide-collection/health.svg)](https://phpackages.com/packages/lordmonoxide-collection)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[qiniu/php-sdk

Qiniu Resource (Cloud) Storage SDK for PHP

8483.0M240](/packages/qiniu-php-sdk)[sylius/resource-bundle

Resource component for Sylius.

23410.2M173](/packages/sylius-resource-bundle)[microsoft/azure-storage-blob

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.

5516.0M60](/packages/microsoft-azure-storage-blob)

PHPackages © 2026

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