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

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

rpillz/laravel-settings
=======================

Laravel app settings stored in the database

00[3 PRs](https://github.com/RPillz/laravel-settings/pulls)PHP

Since Nov 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/RPillz/laravel-settings)[ Packagist](https://packagist.org/packages/rpillz/laravel-settings)[ RSS](/packages/rpillz-laravel-settings/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laravel app settings stored in the database
===========================================

[](#laravel-app-settings-stored-in-the-database)

[![Latest Version on Packagist](https://camo.githubusercontent.com/98c8a1ebf84d26861c856ffd660bca6bcf9c18e20d382ad67a4280c7c98f0081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7270696c6c7a2f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rpillz/laravel-settings)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a3ca9d057aaa82190234fc7577d20973a3748ae16b330bdc9d3dad3477cec1b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7270696c6c7a2f6c61726176656c2d73657474696e67732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/rpillz/laravel-settings/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/bfbbc1961a6c9f0876d50ab4e91df2ed56afdae399007efcfdcc548bdafc0027/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7270696c6c7a2f6c61726176656c2d73657474696e67732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/rpillz/laravel-settings/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/fd07e9a57f799c63bdc87bfb0609bfa3a788c18d350c165cebe3452028744692/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7270696c6c7a2f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rpillz/laravel-settings)

This package will set and get key-value settings from your Laravel app database. It was originally designed to work with a multi-tenant app, which is why the settings were stored in a database and not the standard config files.

There are probably other packages which do a similar thing. You should probably use one of those. ;)

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

[](#installation)

You can install the package via composer:

```
composer require rpillz/laravel-settings
```

You can publish and run the migrations with:

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

You can publish the config file with:

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

This is the contents of the published config file:

```
return [
    // these default settings will be used if there is nothing saved in the database using the same key.
    'defaults' => [

        'default-key' => 'Default Value',
        'is-this-true' => true,

    ]
];
```

Usage
-----

[](#usage)

Primary usage is through a Facade.

```
Settings::get('default-key'); // returns 'Default Value' from the config file.

Settings::set('default-key', 'My New Value'); // updates this setting in the database.

// Beware of cached values
Settings::get('default-key'); // will still return the original 'Default Value'.

// Get the latest value
Settings::fresh('default-key');
Settings::get('default-key', true); // passing a true with get() is the same as fresh()
```

You can add setting values with different type casts.

```
Settings::set('default-key', 'My New Value', 'string'); // string is default. What goes in is what comes out.

Settings::set('default-key', 'My New Value', 'array'); // convert string into single array value

Settings::set('numbers', 'one, two, three', 'csv'); // convert csv string into array

Settings::set('is_active', 1, 'boolean'); // convert value into boolean
```

You can remove settings.

```
Settings::forget('this-setting'); // temporarily nulls in the settings cache (for current page load only)

Settings::delete('this-setting'); // removes setting from the cache and the database.
```

Use the fluent for() function to set things for a specific model. You may use this for unique settings, or to override defaults.

```
Settings::set('this-setting-is', 'on base');

Settings::for($model)->set('this-setting-is', 'on model');
```

Note that the for() function can be made "sticky" by passing true as the second argument and all uses of settings after will maintain the set model.

```
Settings::for($model, true)->set('this-setting-is', 'on model');

Settings::set('this-setting-is', 'still on model');

Settings::resetModel(); // to clear out the sticky model.
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ryan Pilling](https://github.com/RPillz)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1eb94636b8a82af206a0eb37ea6c32e806d71e7e0af03ce29055a32b8f402157?d=identicon)[RPillz](/maintainers/RPillz)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![RPillz](https://avatars.githubusercontent.com/u/9386244?v=4)](https://github.com/RPillz "RPillz (12 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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