spatie/valuestore
Easily store and retrieve simple key-value data in a JSON file. Valuestore offers a lightweight, framework-friendly API for persisting settings, counters, and small bits of state without needing a database, with atomic writes and optional caching.
composer require spatie/valuestoreuse Spatie\ValueStore\Facades\Valuestore;
Valuestore::put('feature_flags', ['dark_mode' => true]);
storage/app/valuestore.json—override via config if needed)Valuestore::put('last_deploy_hash', git rev-parse HEAD).Start by checking the examples/ directory in the repo for minimal usage snippets. In Laravel, you’ll get Valuestore facade out-of-the-box after installation.
config/app.php (e.g., Valuestore::put('maintenance_mode', true) instead of editing .env or DB)if (Valuestore::get('features.new_checkout', false)) { ... }
Valuestore::remember('api_response_cache', 300, fn() => expensiveApiCall());
Valuestore::put('test_session_id', $id);
$this->assertEquals($id, Valuestore::get('test_session_id'));
For Laravel, extend via Valuestore::extend('custom_key', $callback) to support dynamic default values with fallback logic.
remember() only works for the current request lifecycle unless manually persisted. For persistent cache with expiration, layer with Laravel’s cache or manually encode timestamps.$data = Valuestore::get('foo'); $data['bar'] = 1;) won’t persist—always re-save: Valuestore::put('foo', $data)Valuestore instance via Valuestore::fake() or Valuestore::spy() to avoid filesystem side effectsnew Valuestore(\Storage::path('custom.json'))Valuestore::all() reveals full contents—use in tinker or debug middleware to inspect stored data.How can I help you explore Laravel packages today?