PHPackages                             webparking/laravel-type-safe-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. [Database &amp; ORM](/categories/database)
4. /
5. webparking/laravel-type-safe-collection

ActiveLibrary[Database &amp; ORM](/categories/database)

webparking/laravel-type-safe-collection
=======================================

This package provides type-safe extension of the laravel collection, forcing a single type of object.

1.1.0(5y ago)378.2k2MITPHPPHP &gt;=7.1.0CI failing

Since Sep 3Pushed 5y ago3 watchersCompare

[ Source](https://github.com/webparking/laravel-type-safe-collection)[ Packagist](https://packagist.org/packages/webparking/laravel-type-safe-collection)[ RSS](/packages/webparking-laravel-type-safe-collection/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (9)Versions (4)Used By (0)

 Laravel Type-Safe Collection
==============================

[](#--laravel-type-safe-collection)

 [ ![Build Status](https://camo.githubusercontent.com/642e0438cd21f93a9733af08a94a7679ee8122a752830e5317322d40db7b539d/68747470733a2f2f7472617669732d63692e6f72672f7765627061726b696e672f6c61726176656c2d747970652d736166652d636f6c6c656374696f6e2e7376673f6272616e63683d6d6173746572) ](https://travis-ci.org/webparking/laravel-type-safe-collection) [ ![Quality score](https://camo.githubusercontent.com/c9f29fdf2ca026c8e77429d7f71019a8c8011f0cb4395a3fbcdfb5494d654f48/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7765627061726b696e672f6c61726176656c2d747970652d736166652d636f6c6c656374696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572) ](https://scrutinizer-ci.com/g/webparking/laravel-type-safe-collection/?branch=master) [ ![Code coverage](https://camo.githubusercontent.com/9796405f1f658479d9679b1ce0f4f77454439d6e6a7a4445bb0c08be093550f8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7765627061726b696e672f6c61726176656c2d747970652d736166652d636f6c6c656374696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572) ](https://scrutinizer-ci.com/g/webparking/laravel-type-safe-collection/?branch=master)

PHP is getting more mature and allows us to program strong typed in new ways with each new version, however we still lack the option to have generic lists/arrays. This package aims to provide such a thing in the meantime.

The `TypeSafeCollection` provided by this package will make sure that any object within it is the object you expect.

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

[](#installation)

Add this package to composer.

```
composer require webparking/laravel-type-safe-collection

```

Usage
-----

[](#usage)

```
/**
 * @method \ArrayIterator|User[] getIterator()
 * @method User|null             first()
 */
class UserCollection extends TypeSafeCollection
{
    protected $type = User::class;
}
```

```
class User extends Model
{
    public function newCollection(array $models = []): UserCollection
    {
        return new UserCollection($models);
    }
}
```

All queries on User that would result in a Collection will now result in a UserCollection.

```
get_class(User::all()) // UserCollection
get_class(User::where('type', '=', 'admin')->get()) // UserCollection
get_class(User::where('id', '=', 1)->first()) // User
```

Licence and Postcardware
------------------------

[](#licence-and-postcardware)

This software is open source and licensed under the [MIT license](LICENSE.md).

If you use this software in your daily development we would appreciate to receive a postcard of your hometown.

Please send it to: Webparking BV, Cypresbaan 31a, 2908 LT Capelle aan den IJssel, The Netherlands

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~373 days

Total

2

Last Release

2071d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e4c13a922e35b870f1597342981cd03943dfe18ce900859736a54a1cb65bfc0?d=identicon)[crashkonijn](/maintainers/crashkonijn)

---

Top Contributors

[![remkobrenters](https://avatars.githubusercontent.com/u/4686406?v=4)](https://github.com/remkobrenters "remkobrenters (1 commits)")[![RVxLab](https://avatars.githubusercontent.com/u/46111684?v=4)](https://github.com/RVxLab "RVxLab (1 commits)")

---

Tags

phptypelaraveldatabasesafecollectioncollectionstypesafe

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webparking-laravel-type-safe-collection/health.svg)

```
[![Health](https://phpackages.com/badges/webparking-laravel-type-safe-collection/health.svg)](https://phpackages.com/packages/webparking-laravel-type-safe-collection)
```

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[kdabrow/seeder-once

Run your laravel seeders only once

19160.9k](/packages/kdabrow-seeder-once)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40111.7k1](/packages/sebastiaanluca-laravel-boolean-dates)[webparking/laravel-db-rebuild

A laravel package that allows for quick database rebuilds with presets.

448.8k](/packages/webparking-laravel-db-rebuild)

PHPackages © 2026

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