PHPackages                             janiskelemen/laravel-setting - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. janiskelemen/laravel-setting

ActiveLibrary[Localization &amp; i18n](/categories/localization)

janiskelemen/laravel-setting
============================

Laravel Settings Manager

2.2.1(4mo ago)5115.6k↓22.2%11[2 PRs](https://github.com/janiskelemen/laravel-setting/pulls)MITPHPCI failing

Since Jan 21Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/janiskelemen/laravel-setting)[ Packagist](https://packagist.org/packages/janiskelemen/laravel-setting)[ Docs](https://github.com/janiskelemen/laravel-setting)[ RSS](/packages/janiskelemen-laravel-setting/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (27)Used By (0)

Advanced Settings Manager for Laravel
=====================================

[](#advanced-settings-manager-for-laravel)

[![Total Downloads](https://camo.githubusercontent.com/036c8f67f866ce389c5039394ef805b8be5aafe57b92eda5400a0e4bd5aa17b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616e69736b656c656d656e2f6c61726176656c2d73657474696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/janiskelemen/laravel-setting)[![Build Status](https://camo.githubusercontent.com/9adeed8265ff07ab19cf477e139794b9a4d7d3deb66cd6b7b5d0971315126a3a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a616e69736b656c656d656e2f6c61726176656c2d73657474696e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/janiskelemen/laravel-setting)

- 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
- Settings are cached

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

[](#installation)

Via Composer

```
composer require janiskelemen/laravel-setting
```

Publish config and migration
----------------------------

[](#publish-config-and-migration)

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

Setup your settings config
--------------------------

[](#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.

```
# config/setting.php
return [
    'app_name' => 'My Application',
    'user_limit' => 10,
];
```

```
Setting::get('app_name');
//retruns
'My Application'
```

### You can also use multi level arrays

[](#you-can-also-use-multi-level-arrays)

```
# config/setting.php
return [
    'priorities' => [
        'low' => 1,
        'medium' => 2,
        'hight' => 3
    ],
];
```

```
Setting::get('priorities.medium');
//retruns
2
```

### Defining optional config values

[](#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.

```
# config/setting.php
return [
    'app_name' => [
        'type' => 'text', /* Optional config values */
        'max' => 255, /* Optional config values */
        'default_value' => 'My Application' /*  10,
];
```

```
Setting::get('app_name');
//retruns
'My Application'

// You can still access the optional parameters
Setting::get('app_name.max');
//retruns
255
```

### Get full structure with default\_value keys

[](#get-full-structure-with-default_value-keys)

By suffixing your key name with a dot or by using the `Setting::getWithDefaultSubKeys('app_name')` method will return all default parameters including the current value

```
Setting::get('app_name.');
//retruns
[
    'type' => 'text',
    'max' => 255,
    'default_value' => 'My Application',
    'value' => 'My Custom Application Name' //the value key will be added with the current value saved in the database (or default if not in database yet)
]
```

### Scoped settings

[](#scoped-settings)

You might want to save some settings only for a certain user. You can do this using a placeholder (\_\*) inside your config key name.

```
# config/setting.php
return [
    'user_*' => [
        'dark_mode' => false,
        'permissions' => [
            'read' => true,
            'write' => false,
        ]
    ],
];
```

Set save the new setting on runtime:

```
// Save a new setting under user_1.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");
//returns
false
```

Get only the changed user settings

```
Setting::set("user_{$otherUser->id}.dark_mode", true);
Setting::set("user_{$otherUser->id}.permissions.write", true);

Setting::get("user_{$otherUser->id}");
//returns
[
    'dark_mode' => true,
    'permissions' => [
        'write' => false
    ]
]
```

In order to get all user settings you can use the `getWithDefaultSubKeys()` method or suffix the main key with a dot. The result will return a merged array with the default values from and the config while the changed values from the database will overwrite the default values.

```
Setting::get("user_{$otherUser->id}.");
// same as
Setting::getWithDefaultSubKeys("user_{$otherUser->id}");

//returns
[
    'dark_mode' => true, // this value comes from the database
    'permissions' => [
        'read' => true, // this value is the default from the config
        'write' => false, // this value is the default from the config
    ]
]
```

Usage
-----

[](#usage)

```
Setting::get('name');
// 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.

Setting::all();
// 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

Setting::has('name');
// check the key exists in database, return boolean

Setting::lang('zh-TW')->has('name');
// check the key exists by language in database, return boolean

Setting::forget('name');
// delete the setting from database by key

Setting::lang('zh-TW')->forget('name');
// delete the setting from database by key and language
```

Dealing with locale
-------------------

[](#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.

```
Setting::lang(App::getLocale())->langResetting(false);
```

Custom Setting Model
--------------------

[](#custom-setting-model)

The Setting model can be overwritten by creating a /config/laravel-setting.php config and adding:

```
'model' => \App\YourModelName::class,
```

Your custom model needs to extend the **\\JanisKelemen\\Setting\\EloquentStorage** class.

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please send me a DM on Twitter [@janiskelemen](https://twitter.com/janiskelemen) instead of using the issue tracker.

Credits
-------

[](#credits)

This package is mostly a fork of [UniSharp/laravel-settings](https://github.com/UniSharp/laravel-settings)

- [HelpSpace.io](https://helpspace.io/?ref=laravel-setting)
- [Janis Kelemen](https://twitter.com/janiskelemen)
- [All Contributors](../../contributors%5D)

License
-------

[](#license)

MIT. Please see the [license file](LICENSE) for more information.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~115 days

Recently: every ~258 days

Total

23

Last Release

126d ago

Major Versions

1.3.0 → 2.0.02022-04-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/41ce0a7670be5be4145b780488d437c3201d24782f6f137f0a0fca436a4d6600?d=identicon)[Janiskelemen](/maintainers/Janiskelemen)

---

Top Contributors

[![janiskelemen](https://avatars.githubusercontent.com/u/20318292?v=4)](https://github.com/janiskelemen "janiskelemen (7 commits)")[![Cannonb4ll](https://avatars.githubusercontent.com/u/3110750?v=4)](https://github.com/Cannonb4ll "Cannonb4ll (1 commits)")

---

Tags

configkey-valuelaravellocalizationmanagersettinglaravelconfigsettingJanisKelemen

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/janiskelemen-laravel-setting/health.svg)

```
[![Health](https://phpackages.com/badges/janiskelemen-laravel-setting/health.svg)](https://phpackages.com/packages/janiskelemen-laravel-setting)
```

###  Alternatives

[mcamara/laravel-localization

Easy localization for Laravel

3.5k9.1M112](/packages/mcamara-laravel-localization)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.3k](/packages/typicms-base)[vemcogroup/laravel-translation

Translation package for Laravel to scan for localisations and up/download to poeditor

135304.0k2](/packages/vemcogroup-laravel-translation)[laravel-latam/spanish

Spanish Package for Laravel

124.2k](/packages/laravel-latam-spanish)

PHPackages © 2026

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