PHPackages                             leewillis77/setting-store - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. leewillis77/setting-store

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

leewillis77/setting-store
=========================

Laravel package to provide a simple model / facade for key/value storage.

4.0.0(3y ago)2583[1 issues](https://github.com/leewillis77/setting-store/issues)GPL-3.0-or-laterPHPPHP ^8.1CI failing

Since Feb 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/leewillis77/setting-store)[ Packagist](https://packagist.org/packages/leewillis77/setting-store)[ Docs](https://github.com/leewillis77/setting-store)[ Fund](https://ecologi.com/ademtisoftware?gift-trees&r=ademtisoftware)[ RSS](/packages/leewillis77-setting-store/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (9)Used By (0)

Setting Store
=============

[](#setting-store)

Laravel 5.5+ package to provide a simple model / facade for key/value storage.

Treeware
--------

[](#treeware)

If you use this package in production, we ask that you [**buy the world some trees**](https://ecologi.com/ademtisoftware?gift-trees) to thank us for our work. By contributing to our forest you’ll be creating employment for local families and restoring wildlife habitats.

[![We offset our carbon footprint via Ecologi](https://camo.githubusercontent.com/95002e2454df18823e8d797ff8f2da6105f3a8b0a26918b1e661b780a3d2fab9/68747470733a2f2f746f6f6c6b69742e65636f6c6f67692e636f6d2f6261646765732f6370772f3565336162643862643532613633303031373162656164623f626c61636b3d74727565266c616e6473636170653d74727565)](https://ecologi.com/ademtisoftware?gift-trees)Installation
------------

[](#installation)

Add the package to your Laravel project using composer:

```
$ composer require leewillis77/setting-store
```

Configuration
-------------

[](#configuration)

Publish the database migration using the following artisan command:

```
$ php artisan vendor:publish --provider="Leewillis77\SettingStore\Providers\ServiceProvider" --tag="migrations"
```

Run the migration to create the storage table.

```
$ php artisan migrate
```

Usage
-----

[](#usage)

#### Store a (string) setting value

[](#store-a-string-setting-value)

```
// Set a value for the key 'foo'
SettingStore::set('foo', 'bar');
```

#### Store a (non-string) setting value

[](#store-a-non-string-setting-value)

```
// Set a value for the key 'foo'. The value will be serialized before storing.
SettingStore::setSerialized('foo', ['bar']);
```

#### Retrieve a (string) setting value

[](#retrieve-a-string-setting-value)

```
// Retrieve a value for the key 'foo'
$value = SettingStore::get('foo');
```

#### Retrieve a (string) setting, with a fallback value

[](#retrieve-a-string-setting-with-a-fallback-value)

```
// Retrieve a value for the key 'foo', or value 'foobar' if not found
$value = SettingStore::get('foo', 'foobar');
```

#### Retrieve a (non-string) setting value

[](#retrieve-a-non-string-setting-value)

```
// Retrieve a value for the key 'foo'. The value will be unserialized before being returned.
SettingStore::getSerialized('foo');
```

#### Retrieve a (non-string) setting value, with a fallback

[](#retrieve-a-non-string-setting-value-with-a-fallback)

```
// Retrieve a value for the key 'foo'
SettingStore::getSerialized('foo', ['bar']);
```

### Accessing the SettingStore

[](#accessing-the-settingstore)

You can access the SettingStore using the `SettingStore` facade, e.g.

```
$value = SettingStore::get('foo');
```

Alternatively, you can inject the repository into your controllers, e.g.

```
