A simple and easy to use key-value store for Laravel 5.5+

v1.1.0 2019-10-01 15:32 UTC

This package is auto-updated.

Last update: 2024-03-22 03:31:28 UTC


A simple and easy to use key-value database store for Laravel 5.5+

All values are stored into database and managed using cache to avoid unecessary queries.

Casting is supported to manage values type.


Full documentation is available at

Quick start

Install the package using composer:

composer install bgaze/laravel-kvstore

Publish the required migration:

php artisan vendor:publish --tag=kvstore

Then create the table:

php artisan migrate

The KvStore facade offers static methods to manage the store content.

// Insert some values:
KvStore::set('value1', 'a string');
KvStore::set('value2', '11111', 'integer');
KvStore::set('value3', ['test' => true], 'array');

// Update value keeping cast type:
KvStore::set('value3', ['test' => false]);

// Update value changing cast type:
KvStore::set('value3', 22222, 'integer');

// Update value removing cast type.
KvStore::set('value3', 22222, false);

// Get value by key:
$value1 = KvStore::get('value1');

// Get value by key, passing a default value:
$value2 = KvStore::get('value2', 'default value');

// Remove an entry by key:

// Remove multiple entries by key:
KvStore::remove(['value1', 'value2']);