Skip to content
Advanced Settings Manager for Laravel
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
config rename default to default_value Jan 21, 2019

Advanced Settings Manager for Laravel

Total Downloads Build Status StyleCI

  • Simple key-value storage
  • Optional config file for default settings supported
  • Support multi-level array (dot delimited keys) structure
  • Supports storing individual user settings
  • Localization supported


Via Composer

composer require janiskelemen/laravel-setting

Publish config and migration

php artisan vendor:publish --tag=setting
php artisan migrate

Setup your settings config

After publishing the setting files you will find a new configuration file: config/setting.php In this config you can define your basic settings like below.

return [
    'app_name' => 'My Application',
    'user_limit' => 10,
//retruns 'My Application'

You can also use multi level arrays

return [
    'priorities' => [
        'low' => 1,
        'medium' => 2,
        'hight' => 3
//retruns 2

Defining optional config values

If you want to store additional data for a particular setting you can do so using an array and name one of the parameters 'default_value' which will be the default for the setting and is what gets returned by Settings::get('app_name') in this case.

return [
    'app_name' => [
        'type' => 'text', /* Optional config values */
        'max' => 255, /* Optional config values */
        'default_value' => 'My Application' /* <- This value will be returned by Setting::get('app_name') if key is not found in DB */
    'user_limit' => 10,
//retruns 'My Application'

// You can still access the optional parameters
//retruns 255

Scoped settings

You might want to save some settings only for a certain users. You can do this using a multi array. Those setting naturally wont life your config file but can be saved during runtime into the Database.

Set save the new setting on runtime:

// Save a new setting under user1.dark_mode with a value of true
Setting::set('user' . $user->id . '.dark_mode', true);

Now you can get the value:

Setting::get('user' . $user->id . '.dark_mode');
//returns true

The above will return null if the setting does not exist for this user. In order to return something else you can set a default as the second parameter:

Setting::get('user' . $otherUser->id . '.dark_mode', false);
//returns false


// get setting value with key 'name'
// If this key is not found in DB then it will return the value defined from the config file or null if the key is also not defined in the config file.

Setting::get('name', 'Joe');
// get setting value with key 'name'
// return 'Joe' if the key does not exists. This will overwrite the default coming from the config file.

// get all settings.
// This will merge the setting.php config file with the values (only where lang is null) found in the database and returns a collection.

Setting::lang('zh-TW')->get('name', 'Joe');
// get setting value with key and language

Setting::set('name', 'Joe');
// set setting value by key

Setting::lang('zh-TW')->set('name', 'Joe');
// set setting value by key and language

// check the key exists in database, return boolean

// check the key exists by language in database, return boolean

// delete the setting from database by key

// delete the setting from database by key and language

Dealing with locale

By default language parameter are being resets every set or get calls. You could disable that and set your own long term language parameter forever using any route service provider or other method.


Change log

Please see the changelog for more information on what has changed recently.


$ composer test


Please see for details.


If you discover any security related issues, please send me a DM on Twitter @janiskelemen instead of using the issue tracker.


This package is mostly a fork of UniSharp/laravel-settings


MIT. Please see the license file for more information.

You can’t perform that action at this time.