PHPackages                             justijndepover/laravel-settings - 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. justijndepover/laravel-settings

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

justijndepover/laravel-settings
===============================

Store settings in your Laravel application

0.13.0(1y ago)22.5kMITPHPCI passing

Since Nov 7Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/justijndepover/laravel-settings)[ Packagist](https://packagist.org/packages/justijndepover/laravel-settings)[ Docs](https://github.com/justijndepover/laravel-settings)[ RSS](/packages/justijndepover-laravel-settings/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

Laravel Settings
================

[](#laravel-settings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1aa39b8e35f34de0077f00860d374253b3c991d11be9599dc25f6c76d6abad37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a757374696a6e6465706f7665722f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/justijndepover/laravel-settings)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/19a43bb80192009f77b20f4d918400453427d0b91bcbdf23c3134bc9f84a5571/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a757374696a6e6465706f7665722f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/justijndepover/laravel-settings)

Store settings in your Laravel application.

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

[](#installation)

You can install the package with composer

```
composer require justijndepover/laravel-settings
```

After installation you can optionally publish your configuration file

```
php artisan vendor:publish --tag="laravel-settings-config"
```

configuration
-------------

[](#configuration)

This is the config file

```
return [

    /**
     * This setting determines what driver you want to use
     * You can overwrite this driver with your own custom one.
     */
    'driver' => \Justijndepover\Settings\Drivers\Database::class,

    /**
     * Automatically store the app locale
     * If this settings is enabled, the app locale will always be stored in database
     * omitting the need to scope your result set:
     *
     * settings()->forLocale(app()->getLocale())->get('name') becomes: settings()->get('name')
     */
    'auto_store_locale' => false,

    /**
     * Duration the system should cache the fetched database results
     * possible values: 'forever', 'current_request', (int) $seconds
    */
    'cache_time' => 'forever',

];
```

If you chose the default database driver, you should publish the migration file and execute it

```
php artisan vendor:publish --tag="laravel-settings-migration"
php artisan migrate
```

Usage
-----

[](#usage)

You have three different ways of interacting with the settings.

### Use the global helper function

[](#use-the-global-helper-function)

```
settings()->get('site_name')
```

### Inject the settings class with dependency injection

[](#inject-the-settings-class-with-dependency-injection)

```
use Justijndepover\Settings\Settings;

class HomeController extends Controller
{
    public function __invoke(Settings $settings)
    {
        $settings->get('site_name');
    }
}
```

### Use the global facade

[](#use-the-global-facade)

```
Settings::get('site_name');
```

all functionality is available with each method.

Examples
--------

[](#examples)

```
// get some value
settings('site_name');

// Is the equivalent of
settings()->get('site_name');

// return a default if no value exists
settings()->get('site_name', 'default');

// store a single value
settings()->set('site_name', 'my-personal-blog');

// store multiple values at once
settings()->set([
    'site_name' => 'my-personal-blog',
    'site_domain' => 'my-personal-blog.com',
]);

// check if a setting exists
settings()->has('site_name');

// delete all settings (both work)
settings()->flush();
settings()->delete();

// delete a single setting (both work)
settings()->forget('site_name');
settings()->delete('site_name');
```

User settings
-------------

[](#user-settings)

In addition to default settings, you can also use this package to store user settings. Add the `HasSettings` trait to your User model

```
use Justijndepover\Settings\Concerns\HasSettings; // add this line

class User
{
    use HasSettings; // add this line
}
```

After installing the trait, you get a `settings` method on your user

```
// access user settings throught the model
$user = User::find(1);
$user->settings()->get('preferred_language');

// access user settings through the settings class
settings()->forUser(1)->get('preferred_language');

// all other methods are available as well
```

Language specific settings
--------------------------

[](#language-specific-settings)

It's possible to store / access settings for specific locales.

```
settings()->forLocale('en')->set('website', 'my-personal-blog.com/en');
```

Note on how this works
----------------------

[](#note-on-how-this-works)

### Caching

[](#caching)

Whenever a read operation is executed, the package will check if the value is present in the cache. If it's not found, a read operation will be performed to the database (all values are fetched) and stored in the cache for other calls to consume.

This means that performing multiple reads (even with multiple keys) will only perform one database call.

If a write operation is performed, the cache is cleared. Resulting in a new read from database when a new settings is queried.

**IMPORTANT**This means the package uses the cache as it's main source, and falls back to the database otherwise. (which is good in most cases) If you change database values directly, you should clear the cache manually.

When working with serverless applications (e.g. AWS Lambda + Bref or Laravel Vapor), this could cause problems if you don't share the cache between the Lambda functions. In this case you should either set your Laravel cache to something like Redis, or disable the cache feature in this package. To do this, publish the configuration file and set the `cache_time` to `0`.

#### Clearing the cache

[](#clearing-the-cache)

It's also possible to clear the cache programmatically:

```
settings()->clearCache();
// or
Settings::clearCache();
```

### User and locale settings

[](#user-and-locale-settings)

The default driver always stores a `locale` and `user_id` field in the database (defaults to `null`). Fetching data from the database will also query on these parameters.

To query something different than `null`, you should chain the `forUser` or `forLocale` between the `setting` and final method.

```
settings()->forUser(1)->get('name');
settings()->forLocale('nl')->get('name');
settings()->forUser(1)->forLocale('nl')->get('name');
```

Security
--------

[](#security)

If you find any security related issues, please open an issue or contact me directly at [justijndepover@gmail.com](justijndepover@gmail.com).

Contribution
------------

[](#contribution)

If you wish to make any changes or improvements to the package, feel free to make a pull request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance57

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.1% 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 ~118 days

Recently: every ~190 days

Total

13

Last Release

586d ago

### Community

Maintainers

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

---

Top Contributors

[![justijndepover](https://avatars.githubusercontent.com/u/9008623?v=4)](https://github.com/justijndepover "justijndepover (52 commits)")[![nick-thieuw](https://avatars.githubusercontent.com/u/255209612?v=4)](https://github.com/nick-thieuw "nick-thieuw (1 commits)")

---

Tags

laravelphpsettingslaravelSettingslaravel-settingsjustijndepover

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/justijndepover-laravel-settings/health.svg)

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

###  Alternatives

[akaunting/laravel-setting

Persistent settings package for Laravel

495805.1k7](/packages/akaunting-laravel-setting)[zachleigh/laravel-property-bag

Easy Laravel user settings using a property bag

85340.3k](/packages/zachleigh-laravel-property-bag)

PHPackages © 2026

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