karriere/state

Laravel package for storing current application state in cache/session
19,819 17
Install
composer require karriere/state
Latest Version:v3.3.0
PHP:^8.2
Laravel:11 · 12
License:Apache-2.0
Last Updated:Jul 27, 2026
Links: GitHub  ·  Packagist
Maintainer: fetzi

    Packagist Downloads

State package for Laravel

This laravel package allows to store a certain application state in either the session or inside a cache.

Installation

Run composer require karriere/state to install this package.

Usage

To enable the package you need to reference the StoreServiceProvider class inside your config/app.php file in the providers section:

'providers' => [
    ...
    Karriere\State\StateServiceProvider::class,
    ...
];

To store the application state you create a state object and store it:

$state = $stateFactory->build('state-name', ['key' => 'value']);
$store->put($state);

// pass on $state->identifier()

In a later situation where you have the state identifier you can access the states data by:

$state = $store->get($identifier);

if(!$state->isEmpty()) {
  // use either $state->collection() or $state->raw() to access the state data
}

Configuration

To install the configuration file you simply use:

php artisan vendor:publish

Options

  • storage: session|cache
  • storage-prefix: prefix that is added to the store identifier
  • expires-after: defines the expires after time in seconds, only used for CacheStore

License

Apache License 2.0 Please see LICENSE for more information.

Related Packages

valeryq/cacheable

Laravel Cacheable

101 5
kronthto/laravel-oauth2-login

Provides a middleware to protect resources requiring an OAuth2 login

17,586 21
ytake/laravel-couchbase

Couchbase providers for Laravel

52,526 30
ytake/laravel-voltdb

VoltDB providers for Laravel

37 4

Version History

Version Released PHP Laravel License
v3.3.0 ^8.2 ^11.0 | ^12.0 Apache-2.0
v3.2.0 8.1.* || 8.2.*|| 8.3.* || 8.4.* ^10.0 || ^11.0 || ^12.0 Apache-2.0
v3.1.0 8.1.* || 8.2.*|| 8.3.* ^10.0 || ^11.0 Apache-2.0
v3.0.0 8.0.* | 8.1.* | 8.2.* ^9.0 || ^10.0 Apache-2.0
v2.2.0 ^7.4 | ^8.0 ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 Apache-2.0