PHPackages                             cornford/setter - 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. [Database &amp; ORM](/categories/database)
4. /
5. cornford/setter

ActiveLibrary[Database &amp; ORM](/categories/database)

cornford/setter
===============

An easy way to integrate Database Settings with Laravel.

v3.0.0(6y ago)131.0k4[2 issues](https://github.com/bradcornford/Setter/issues)MITPHPPHP &gt;=7.2CI failing

Since May 29Pushed 6y ago2 watchersCompare

[ Source](https://github.com/bradcornford/Setter)[ Packagist](https://packagist.org/packages/cornford/setter)[ RSS](/packages/cornford-setter/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (56)Used By (0)

An easy way to intergrate Database Settings with Laravel
========================================================

[](#an-easy-way-to-intergrate-database-settings-with-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/beba4bc1a25c53db73864d3dce28bc7ab7b5c1d2685d395a9e85931d6265772d/68747470733a2f2f706f7365722e707567782e6f72672f636f726e666f72642f7365747465722f76657273696f6e2e706e67)](https://packagist.org/packages/cornford/setter)[![Total Downloads](https://camo.githubusercontent.com/7bf4cf864840a607bf352062668c54f5d7a0a8cdd45ebef1ab8ac58900963405/68747470733a2f2f706f7365722e707567782e6f72672f636f726e666f72642f7365747465722f642f746f74616c2e706e67)](https://packagist.org/packages/cornford/setter)[![Build Status](https://camo.githubusercontent.com/39a4edcbc865b157b56760dd99c9eee3b615119e978bc4b289b8d4f4b71beb11/68747470733a2f2f7472617669732d63692e6f72672f62726164636f726e666f72642f5365747465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bradcornford/Setter)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5aa1eba68545354d8ec9b21bf28992b200b9a4d4b4cdf6fc15a760a989cc03f2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62726164636f726e666f72642f5365747465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bradcornford/Setter/?branch=master)

### For Laravel 5.x, check [version 2.4.0](https://github.com/bradcornford/Setter/tree/v1.5.5)

[](#for-laravel-5x-check-version-240)

### For Laravel 4.x, check [version 1.7.2](https://github.com/bradcornford/Setter/tree/v1.5.5)

[](#for-laravel-4x-check-version-172)

Think of Setter as an easy way to integrate Settings with Laravel, providing a variety of helpers to speed up the utilisation of application wide settings. These include:

- `Setting::set`
- `Setting::get`
- `Setting::forget`
- `Setting::has`
- `Setting::all`
- `Setting::clear`
- `Setting::expires`

Installation
------------

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/setter`.

```
"require": {
	"cornford/setter": "3.*"
}

```

Next, update Composer from the Terminal:

```
composer update

```

We now have to publish the packages assets with the following command:

```
php artisan vendor:publish --provider="Cornford\Setter\Providers\SettingServiceProvider" --tag=setting

```

We now have to migrate the package database table with the following command:

```
php artisan migrate

```

Once this operation completes, the next step is to add the service provider. Open `config/app.php`, and add a new item to the providers array.

```
Cornford\Setter\Providers\SettingServiceProvider::class,

```

The final step is to introduce the facade. Open `config/app.php`, and add a new item to the aliases array.

```
'Setting' => Cornford\Setter\Facades\SettingFacade::class,

```

That's it! You're all set to go.

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

[](#configuration)

You can now configure Setter in a few simple steps. Open `config/packages/cornford/setter/config.php` and update the options as needed.

- `cache` - Enable caching to improve performance by reducing database calls.
- `tag` - A tag prefixed to all cache items, e.g. tag::.
- `expiry` - The default expiry for cache items, e.g. 60.

Usage
-----

[](#usage)

It's really as simple as using the Setter class in any Controller / Model / File you see fit with:

`Setting::`

This will give you access to

- [Set](#set)
- [Get](#get)
- [Forget](#forget)
- [Has](#has)
- [All](#all)
- [Clear](#clear)
- [expires](#expires)
- [Uncached](#uncached)
- [cacheEnabled](#cache-enabled)
- [enableCache](#enable-cache)
- [disableCache](#disable-cache)
- [setCacheTag](#set-cache-tag)
- [getCacheTag](#get-cache-tag)
- [cacheHas](#cache-has)
- [cacheForget](#cache-forget)
- [cacheClear](#cache-clear)
- [CacheExpires](#cache-expires)

### Set

[](#set)

The `set` method sets a setting via both a key and a value parameter in the database.

```
Setting::set('app.url', 'http://localhost');

```

### Get

[](#get)

The `get` method gets a setting via a key parameter from the database, and a default value can be optionally passed if the setting doesn't exist. If no default parameter is supplied, and an application configuration variable is present, this will be returned.

```
Setting::get('app.url', 'http://localhost');
Setting::get('app.url');

```

### Forget

[](#forget)

The `forget` method removes a setting via a key parameter from the database.

```
Setting::forget('app.setting');

```

### Has

[](#has)

The `has` method returns a true / false based on if a setting is present in the database via a key parameter. This doesn't fall back to checking application configuration variables.

```
Setting::has('app.setting');

```

### All

[](#all)

The `all` method returns an array of key value pairs of settings from the database. This doesn't fall back to return application configuration variables.

```
Setting::all();

```

### Clear

[](#clear)

The `clear` method removes all settings from the database. This doesn't fall back to removing application configuration variables.

```
Setting::clear();

```

### Expires

[](#expires)

The `expires` method sets the cache expiry setting. Can be false to not cache, true / 0 to cache indefinitely, an integer for minutes, or a datetime of when to expire.

```
Setting::expires(false);

```

### Uncached

[](#uncached)

The `uncached` method ensures the next get request is requested from the database rather than the cache. It will also re-cache the item if one is found.

```
Setting::uncached();
Setting::uncached()->get('app.setting');

```

### Cache Enabled

[](#cache-enabled)

The `cacheEnabled` method gets the current caching state returning a true / false based on the cache status, retuning the current Setter instance.

```
Setting::cacheEnabled();

```

### Enable Cache

[](#enable-cache)

The `enableCache` method sets caching state to cache items, retuning the current Setter instance.

```
Setting::enableCache();
Setting::enableCache()->set('app.url', 'http://localhost');

```

### Disable Cache

[](#disable-cache)

The `disableCache` method sets caching state to not cache items.

```
Setting::disableCache();
Setting::disableCache()->set('app.url', 'http://localhost');

```

### Set Cache Tag

[](#set-cache-tag)

The `setCacheTag` method sets the currently caching prefix tag.

```
Setting::setCacheTag('tag:');

```

### Get Cache Tag

[](#get-cache-tag)

The `getCacheTag` method gets the currently set caching prefix tag.

```
Setting::getCacheTag();

```

### Cache Has

[](#cache-has)

The `cacheHas` method returns a true / false based on if a setting is present in the cache via a key parameter. This doesn't fall back to checking application configuration variables.

```
Setting::cacheHas('app.setting');

```

### Cache Forget

[](#cache-forget)

The `cacheForget` method removes a setting via a key parameter from the cache.

```
Setting::cacheForget('app.setting');

```

### Cache Expires

[](#cache-expires)

The `cacheExpires` method sets the cache expiry setting. Can be false to not cache, true / 0 to cache indefinitely, an integer for minutes, or a datetime of when to expire.

```
Setting::cacheExpires(false);

```

### Cache Clear

[](#cache-clear)

The `cacheClear` method removes all settings from the cache. This doesn't fall back to removing application configuration variables.

```
Setting::cacheClear();

```

### License

[](#license)

Setter is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~0 days

Total

54

Last Release

2267d ago

Major Versions

v1.5.6.x-dev → v2.1.02016-06-14

v1.5.7.x-dev → v2.1.22016-06-17

v1.6.0 → v2.2.02017-06-05

v1.7.2 → v2.3.12018-07-18

v2.1.3 → v3.0.02020-03-04

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/fcf41bf377df077c60272fea95b86b221e6923caa6f4075a519ac161186534ed?d=identicon)[bradcornford](/maintainers/bradcornford)

---

Top Contributors

[![bradcornford](https://avatars.githubusercontent.com/u/2913887?v=4)](https://github.com/bradcornford "bradcornford (8 commits)")

---

Tags

laravelconfigurationconfigdatabasesetting

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cornford-setter/health.svg)

```
[![Health](https://phpackages.com/badges/cornford-setter/health.svg)](https://phpackages.com/packages/cornford-setter)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[illuminatech/config

Provides support for Laravel application runtime configuration managed in persistent storage

14921.0k1](/packages/illuminatech-config)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
