PHPackages                             motomedialab/runtime-store - 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. motomedialab/runtime-store

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

motomedialab/runtime-store
==========================

Store data to be shared across application for the duration of the applications runtime

v1.3.1(4y ago)22.5kMITPHPPHP ^8.0CI failing

Since Sep 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/motomedialab/runtime-store)[ Packagist](https://packagist.org/packages/motomedialab/runtime-store)[ Docs](https://github.com/motomedialab/runtime-store)[ RSS](/packages/motomedialab-runtime-store/feed)WikiDiscussions master Synced 1mo ago

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

Runtime data store - simple runtime value caching
=================================================

[](#runtime-data-store---simple-runtime-value-caching)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3107dad77b5502363887d4681df3de5c2763ab7a48829399a6ada280350be484/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f746f6d656469616c61622f72756e74696d652d73746f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/motomedialab/runtime-store)
[![StyleCI Code Quality](https://camo.githubusercontent.com/c565566094a4c2eb5ae1d391c01e5a3bb52fe0e14402d5123f30ea7633a4fce9/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3231313238383538352f736869656c643f7374796c653d666c61742d737175617265)](https://github.styleci.io/repos/211288585)
[![Build Status](https://camo.githubusercontent.com/2eace006e78fea693c41085a102f79cb448900b6f66958cba74b397997fed2a0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d6f746f6d656469616c61622f72756e74696d652d73746f72652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/motomedialab/runtime-store)
[![Total Downloads](https://camo.githubusercontent.com/317367999c3286a3c2aad128f55e04d14e8c15b048653403fbad185c3aa30d1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f746f6d656469616c61622f72756e74696d652d73746f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/motomedialab/runtime-store)

A simple framework-agnostic package (that plays particularly nicely with Laravel's app container, [see here](#accessing-the-store)) that allows caching of values for the duration of a requests lifetime.

This is particularly useful in cases where scripts may be called on multiple times and depend on
third parties or query calls to return data.

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

[](#installation)

You can install the package via composer:

```
composer require motomedialab/runtime-store
```

Usage
-----

[](#usage)

Runtime store comes with a global helper `store()` which uses the singleton pattern and we recommend using.
However, there are multiple ways of accessing the Runtime Store as its framework agnostic, [see here](#accessing-the-store).

The package utilises a similar API to Laravel's `cache` and `session` helpers, as demonstrated below.

```
// set a value
store()->set('key', 'value')
store()->put('key', 'value')
store()->add('key', 'value')

// check a value exists
store()->has('key')

// retrieve a value
store()->get('key'); // will return value
store()->get('key', 'default'); // has a default value

// remember a value once set
store()->remember('key', function () {

  // remember method will only execute the callback
  // once per runtime and return the stored value
  // on additional calls.

  return ['data' => 'value'];
});

// increment / decrement numerical values
store()->increment('key', 1)
store()->decrement('key', 1)

// forget a value after retrieving
store()->pull('key')

// forget a value/ multiple values
store()->forget('key')
store()->delete('key')
store()->forget(['key1', 'key2'])

// forget all values
store()->clear()
```

### Grouping

[](#grouping)

As of v1.2, you can create groups. Groups have the exact same API as above, with a few extras methods to easily create and delete groups.

```
// creating a group and setting your first value...
store()->group('groupName')->set('key', 'value')

// getting a key from a group
store()->group('groupName')->get('key')

// checking if a group exists
store()->hasGroup('groupName')

// deleting a group
store()->deleteGroup('groupName')
```

---

### Accessing the store

[](#accessing-the-store)

There are many ways to access the store and you can write your own implementation quickly and easily.

```
// in Laravel, there are multiple ways to resolve a global instance of the store...
app(\Motomedialab\RuntimeStore\RuntimeStore::class)->get('value');
\Motomedialab\RuntimeStore\RuntimeStoreFacade::get('value');
app('store')->get('value');
resolve('store')->get('value');

// there is a global store() helper method, demonstrated below.
// this also integrates with Laravel's application layer directly (when installed).
store()->get('value');
```

#### Accessing from within a class

[](#accessing-from-within-a-class)

We've built a handy trait which you can use in your classes to instantly boot up a grouped store, scoped to that class name. In the example below, any values will be set within a group called `YourClass` automatically.

```
class YourClass {
  use \Motomedialab\RuntimeStore\Traits\HasRuntimeStore;

  public function yourMethod()
  {
    return $this->store()->remember('key', function () {
      return 'This value will be remembered as long as the request is active!';
    });
  }
}
```

#### Further implementations

[](#further-implementations)

We've covered off pretty much everything above but if you're looking to implement the RuntimeStore in your own way, here's a couple of examples...

```
// procedual example
$store = null;
function store() {
    global $store;

    if ($store) {
      return $store;
    }

    return $store = new \Motomedialab\RuntimeStore\RuntimeStore;
}
```

```
// OOP example
class ClassWithStore {
  protected $store;

  public function store() {
    if ($this->store) {
      return $this->store;
    }

    return $this->store = new \MotoMediaLab\RuntimeStore\RuntimeStore;
  }
}
```

---

### Testing

[](#testing)

We've carried out extensive testing to make sure everything works as expected, but feel free to try it yourself!

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com), a super handy
package templating application.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~208 days

Total

5

Last Release

1587d ago

PHP version history (4 changes)v1.0.0PHP ^7.2

v1.0.1PHP ^7.1

v1.3.0PHP ^7.1|^8.0

v1.3.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/805ae1048fb81d8f02871f57cc0a34699089da17f7021210e554ffdba4df918a?d=identicon)[chrispage1](/maintainers/chrispage1)

---

Top Contributors

[![chrispage1](https://avatars.githubusercontent.com/u/2487374?v=4)](https://github.com/chrispage1 "chrispage1 (34 commits)")

---

Tags

motomedialabruntime-store

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/motomedialab-runtime-store/health.svg)

```
[![Health](https://phpackages.com/badges/motomedialab-runtime-store/health.svg)](https://phpackages.com/packages/motomedialab-runtime-store)
```

###  Alternatives

[cjmellor/level-up

This package allows users to gain experience points (XP) and progress through levels by performing actions on your site. It can provide a simple way to track user progress and implement gamification elements into your application

66188.9k](/packages/cjmellor-level-up)[motomedialab/laravel-vite-helper

A helper method to generate absolute asset URL's to Vite assets

29571.0k2](/packages/motomedialab-laravel-vite-helper)[motomedialab/simple-laravel-audit

A simple audit helper that integrates directly with Laravel &amp; FilamentPHP

262.7k](/packages/motomedialab-simple-laravel-audit)[motomedialab/laravel-self-healing-urls

Generate self-healing URLs for models

252.7k](/packages/motomedialab-laravel-self-healing-urls)

PHPackages © 2026

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