karriere / state
Laravel package for storing current application state in cache/session
Installs: 14 726
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: 8.1.* || 8.2.*|| 8.3.*
- illuminate/session: ^10.0 || ^11.0
- illuminate/support: ^10.0 || ^11.0
- psr/cache: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- laravel/pint: ^1.6
- mockery/mockery: ^1.0
- pestphp/pest: ^2.0
- phpstan/phpstan: ^1.10
README
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|cachestorage-prefix
: prefix that is added to the store identifierexpires-after
: defines the expires after time in seconds, only used forCacheStore
License
Apache License 2.0 Please see LICENSE for more information.