spatie/laravel-valuestore
Store and retrieve loose key/value data in a JSON file with a simple API. Supports put/get with defaults, has/all, forget/flush, increment, and helpers like ArrayAccess and Countable—handy for app settings or small persistent state.
storage/app/valuestore.json by default).ValuestoreSaved, ValuestoreFlushed).Valuestore interface.Storage::lock()).spatie/laravel-settings with database).storage/app should be writable only by the web server user).config/encryption.php).flush() carefully in production.)Valuestore? (e.g., use a shared filesystem or database.)spatie/laravel-settings (structured, queryable).Illuminate\Support\Facades\Cache (ephemeral, distributed)..env (immutable, non-code).league/flysystem (if using cloud storage like S3).spatie/laravel-caching (to cache the JSON file in memory).spatie/laravel-settings if relational data or querying is needed.laravel/redis or predis/predis for distributed caching.Valuestore interface for isolated tests.Storage facade.storage/app/debug-config.json) to avoid risk.Valuestore (e.g., Valuestore::get('app.debug')).$value = Cache::remember('valuestore_key', now()->addHours(1), function () {
return Valuestore::get('key');
});
Valuestore for critical data (e.g., via Valuestore interface).config() as a fallback for missing keys.composer.json constraints).flysystem.composer require spatie/laravel-valuestore.php artisan vendor:publish --tag="valuestore-config".config/valuestore.php:
'path' => storage_path('app/valuestore.json'),
public function __construct(private Valuestore $valuestore) {}
AppServiceProvider for global access:
$this->app->singleton(Valuestore::class, function ($app) {
return Valuestore::make($app['config']['valuestore.path']);
});
tail -f storage/app/valuestore.json).Valuestore::make($path)->put('key', $value);
Log::debug('Valuestore updated', ['key' => 'key', 'value' => $value]);
storage/app/valuestore.json not writable).storage/app/valuestore-*.json).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| File system full | Writes fail, data loss | Monitor disk space, set up alerts. |
| File permission denied | No reads/writes | Ensure correct permissions (chmod 644). |
How can I help you explore Laravel packages today?