outerweb/settings

Application wide settings stored in your database
137,627 51
Install
composer require outerweb/settings
Latest Version:v2.0.3
PHP:^8.4
License:MIT
Last Updated:Apr 27, 2026
Links: GitHub  ·  Packagist
Maintainer: outerweb.be

Settings

Settings

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides application wide settings stored in your database

Table of Contents

Installation

You can install the package via composer:

composer require outerweb/settings

Run the install command to publish the migration and the config file:

php artisan settings:install

Usage

This package tries to mimic the Config functionality of Laravel as close as possible.

You can use the Outerweb\Settings\Facades\Setting facade or the setting() helper function to work with your stored settings.

Storing settings

Storing a single setting
use Outerweb\Settings\Facades\Setting;

Setting::set('key', 'value');
// or
setting(['key' => 'value']);
// or
setting()->set('key', 'value');
Storing multiple settings
use Outerweb\Settings\Facades\Setting;

Setting::set([
    'key1' => 'value1',
    'key2' => 'value2',
]);
// or
setting([
    'key1' => 'value1',
    'key2' => 'value2',
]);
// or
setting()->set([
    'key1' => 'value1',
    'key2' => 'value2',
]);
Storing nested settings

You can use "dot" notation to store nested settings:

use Outerweb\Settings\Facades\Setting;

Setting::set('parent.child', 'value');
// or
setting(['parent.child' => 'value']);
// or
setting()->set('parent.child', 'value');

This will store a single table entry with the key parent.child and the value value.

You can also store nested settings using arrays:

use Outerweb\Settings\Facades\Setting;

Setting::set([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);
// or
setting([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);
// or
setting()->set([
    'parent' => [
        'child1' => 'value',
        'child2' => 'value',
    ],
]);

This will store two table entries:

  • parent.child1 with the value value
  • parent.child2 with the value value

Retrieving settings

Retrieving a single setting
use Outerweb\Settings\Facades\Setting;

$value = Setting::get('key');
// or
$value = setting('key');
// or
$value = setting()->get('key');

This will return the value of the setting stored with the key key. If the setting does not exist, it will return null.

You can also provide a default value that will be returned if the setting does not exist:

$value = Setting::get('key', 'default_value');
// or
$value = setting('key', 'default_value');
// or
$value = setting()->get('key', 'default_value');

This will return default_value if the setting with the key key is null or does not exist.

Retrieving a nested setting
use Outerweb\Settings\Facades\Setting;

$value = Setting::get('parent.child');
// or
$value = setting('parent.child');
// or
$value = setting()->get('parent.child');

This will return the value of the setting stored with the key parent.child.

Retrieving multiple settings via parent key

Imagine you have the following settings stored:

  • parent.child1 with the value value1
  • parent.child2 with the value value2
use Outerweb\Settings\Facades\Setting;

$values = Setting::get('parent');
// or
$values = setting('parent');
// or
$values = setting()->get('parent');

This will return an associative array:

[
    'child1' => 'value1',
    'child2' => 'value2',
]
Retrieving multiple settings
use Outerweb\Settings\Facades\Setting;

$values = Setting::get(['parent.child1', 'parent.child2']);
// or
$values = setting(['parent.child1', 'parent.child2']);
// or
$values = setting()->get(['parent.child1', 'parent.child2']);

This will return an associative array:

[
    'parent.child1' => 'value1',
    'parent.child2' => 'value2',
]
Retrieving all settings
use Outerweb\Settings\Facades\Setting;

$values = Setting::get();
// or
$values = setting()->get();

This will return all settings as an associative array.

Type safety

You can use the following methods to ensure type safety when retrieving settings:

String
use Outerweb\Settings\Facades\Setting;

$value = Setting::string('key');
// or
$value = setting()->string('key');

This will make sure the returned value is a string. Otherwise, it will throw an UnexpectedValueException.

Integer
use Outerweb\Settings\Facades\Setting;

$value = Setting::integer('key');
// or
$value = setting()->integer('key');

This will make sure the returned value is an integer. Otherwise, it will throw an UnexpectedValueException.

Float
use Outerweb\Settings\Facades\Setting;

$value = Setting::float('key');
// or
$value = setting()->float('key');

This will make sure the returned value is a float. Otherwise, it will throw an UnexpectedValueException.

Boolean
use Outerweb\Settings\Facades\Setting;

$value = Setting::boolean('key');
// or
$value = setting()->boolean('key');

This will make sure the returned value is a boolean. Otherwise, it will throw an UnexpectedValueException.

Array
use Outerweb\Settings\Facades\Setting;

$value = Setting::array('key');
// or
$value = setting()->array('key');

This will make sure the returned value is an array. Otherwise, it will throw an UnexpectedValueException.

Collection
use Outerweb\Settings\Facades\Setting;

$value = Setting::collection('key');
// or
$value = setting()->collection('key');

This uses the same logic as array() but returns a Illuminate\Support\Collection instance instead of an array.

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

Related Packages

unisharp/laravel-settings

Persistent settings manager for laravel, translations are supported.

175,886 106
smatar/laravel-settings

Simple Settings package for laravel application

2,405 0
cmarfil/laravel-multiuser-json-settings

Simple user json settings facade for Laravel 4.

275 5
arcanedev/laravel-settings

This package allows you to persists configs/settings for Laravel projects.

144,655 74
efriandika/laravel-settings

Laravel 5 Persistent Settings

39,736 54

Version History

Version Released PHP Laravel License
v2.0.3 ^8.4 ^11.0||^12.0||^13.0 MIT
v2.0.2 ^8.4 ^11.0||^12.0 MIT
v2.0.1 ^8.4 ^11.0||^12.0 MIT
v2.0.0 ^8.4 ^11.0||^12.0 MIT
v1.1.0 ^8.0 ^10.0|^11.0|^12.0 MIT