PHPackages                             dan/laravel-cached - 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. dan/laravel-cached

ActiveProject

dan/laravel-cached
==================

Your Laravel models, decorated, cached, and pleasantly accessible.

v0.1.0(4y ago)041.3k↓50%2MITPHPPHP &gt;=7.1

Since Dec 18Pushed 2y ago3 watchersCompare

[ Source](https://github.com/danrichards/laravel-cached)[ Packagist](https://packagist.org/packages/dan/laravel-cached)[ RSS](/packages/dan-laravel-cached/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (26)Used By (0)

Cached (More for Laravel)
=========================

[](#cached-more-for-laravel)

A cache decorator that feels like **more** Laravel.

Highlights
----------

[](#highlights)

### Usage with helper

[](#usage-with-helper)

> Examples

```
// Fetch a model from the cache
$user = cached(User::class, 1);                 // App\User

// The default decorated class or
// CACHE_DECORATOR specified on model.
$u = cached(User::class, 1, $decorate = true)   // More\Laravel\Cached\CacheDecorator

// A specific decorator to be returned
$u = cached(User::class, 1, Dashboard::class);  // App\Presenters\Dashboard

// A specific decorator to be returned
$u = cachedOrFail(User::class, 200000, Dashboard::class);  // throws ModelNotFoundException

```

### Usage with the macro

[](#usage-with-the-macro)

> Examples

```
// Find a model from the cache / db
$user = User::cached($id = 1);                  // App\User

// Find or fail from the cache /db
$user = User::cachedOrFail($id = 200000);       // throws ModelNotFoundException

// Fail with exception or decorate.
$u = User::cachedOrFail($id = 1)->decorate()    // More\Laravel\Cached\CacheDecorator

// Param can be used when model may not be found
$u = User::cached($id = 1, $decorate = true)    // More\Laravel\Cached\CacheDecorator

// A specific decorator to be returned
$u = User::cachedOrFail($id = 1)                // App\Presenters\Dashboard
    ->decorate(Dashboard::class);

// A specific decorator to be returned
$u = User::cached($id = 1, Dashboard::class);   // App\Presenters\Dashboard

```

More on Decorators
------------------

[](#more-on-decorators)

> A basic `CacheDecorator` is included by default. But you can publish the config to switch the global default.

### Default `CacheDecorator`

[](#default-cachedecorator)

```
$ php artisan vendor:publish --provider="\More\Laravel\Cached\Support\CachedServiceProvider"

```

### Model constant `CACHE_DECORATOR`

[](#model-constant-cache_decorator)

> If your decorator demands various cached methods for your model, you can override the global behavior on each model as well.

```
class User extends Model
{
    const CACHE_DECORATOR = \App\Metrics\UserMetrics::class;
}

---

$user->decorate();                              // \App\Metrics\UserMetrics

```

### Decorated on run-time

[](#decorated-on-run-time)

> As you've already seen in the examples at the top, you can specify a decorator you want back at run-time.

Suggestions
-----------

[](#suggestions)

This pattern plays very nice with `hemp/presenter`. Just extend his `Presenter` class, add the trait included, and overload construct.

Additionally, a overloading route-model binding with a drop-in replacement would be cool.

More testing and discovery with nested cache forgetting, and cache pre-warming.

Composer
--------

[](#composer)

```
$ composer require dan/laravel-cached dev-master

```

Contributors
------------

[](#contributors)

- [Diogo Gomes](https://github.com/diogogomeswww)

License
-------

[](#license)

MIT.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64% 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 ~54 days

Recently: every ~207 days

Total

23

Last Release

1524d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.6

v0.0.11PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/058e584a67bb904f19799d08a3609de0af4de77e989d50bcdb27f66f0ecfba14?d=identicon)[danrichards](/maintainers/danrichards)

![](https://avatars.githubusercontent.com/u/219?v=4)[Dan Benjamin](/maintainers/dan)[@dan](https://github.com/dan)

---

Top Contributors

[![diogogomeswww](https://avatars.githubusercontent.com/u/11543163?v=4)](https://github.com/diogogomeswww "diogogomeswww (16 commits)")[![danrichards](https://avatars.githubusercontent.com/u/470255?v=4)](https://github.com/danrichards "danrichards (8 commits)")[![colepizzarella](https://avatars.githubusercontent.com/u/10200684?v=4)](https://github.com/colepizzarella "colepizzarella (1 commits)")

---

Tags

laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dan-laravel-cached/health.svg)

```
[![Health](https://phpackages.com/badges/dan-laravel-cached/health.svg)](https://phpackages.com/packages/dan-laravel-cached)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

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