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

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

egough/laravel-settings
=======================

Database-backed application and model settings for Laravel.

v1.3.1(3mo ago)0885↓47.6%MITPHPPHP ^8.2 || ^8.3 || ^8.4CI passing

Since Feb 25Pushed 3mo agoCompare

[ Source](https://github.com/realedwardgough/laravel-settings)[ Packagist](https://packagist.org/packages/egough/laravel-settings)[ Docs](https://github.com/realedwardgough/laravel-settings)[ RSS](/packages/egough-laravel-settings/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (6)Used By (0)

[![alt text](https://camo.githubusercontent.com/0fd80dec1780cc1e59d82a51f42eee66394d267ecb0b954b998cc46967f92a7c/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323053657474696e67732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d65676f7567682532466c61726176656c2d73657474696e6773267061747465726e3d617263686974656374267374796c653d7374796c655f32266465736372697074696f6e3d476c6f62616c2b2532362b4d6f64656c2b53657474696e6773266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667 "Laravel Settings")](https://camo.githubusercontent.com/0fd80dec1780cc1e59d82a51f42eee66394d267ecb0b954b998cc46967f92a7c/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323053657474696e67732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d65676f7567682532466c61726176656c2d73657474696e6773267061747465726e3d617263686974656374267374796c653d7374796c655f32266465736372697074696f6e3d476c6f62616c2b2532362b4d6f64656c2b53657474696e6773266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/679e060a9cb227a06b738fbbf20d490f6c33bbb23bcc5fab92c406617c6658f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65676f7567682f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/egough/laravel-settings)[![Total Downloads](https://camo.githubusercontent.com/ac406b3e448c65a6f528b47174847498af71bcfd2a765ae0c60d4d19dfb10e7f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f65676f7567682f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/egough/laravel-settings)[![License](https://camo.githubusercontent.com/4cb7caacf8c811aca19e469845f417d428bb55653d92863402ccf364a21670de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f65676f7567682f6c61726176656c2d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/egough/laravel-settings)[![Tests](https://github.com/realedwardgough/laravel-settings/actions/workflows/tests.yml/badge.svg)](https://github.com/realedwardgough/laravel-settings/actions/workflows/tests.yml)

Database-backed application and model settings for Laravel.

Provides a simple, typed and cacheable way to store dynamic configuration outside of `.env` and static config files, including per-model settings such as user or team preferences.

---

Quick Example
-------------

[](#quick-example)

```
// Application setting
settings()->set('site.name', 'My Application');

settings()->get('site.name');

// Model-specific setting
$user->settings()->set('ui.theme', 'dark');

$user->settings()->get('ui.theme');

// Feature flag
if (flag('billing.enabled')) {
    // Feature enabled
}
```

Blade usage:

```
@hasFlag('billing.enabled')

@endhasFlag

@setting('site.name')
```

---

When Should I Use This Package?
-------------------------------

[](#when-should-i-use-this-package)

Use this package when your application needs configuration that can change at runtime without modifying environment variables or deployment configuration.

Typical use cases include:

**Application settings**

- Site name or branding
- Feature toggles
- Maintenance or runtime configuration
- Admin-managed options

**Model settings**

- User preferences (theme, notifications, dashboard layout)
- Team or organisation configuration
- Account-specific options
- Per-project or per-resource metadata

This package is intended for dynamic configuration stored in the database and accessed consistently across your application.

---

### When Not to Use It

[](#when-not-to-use-it)

You should continue using Laravel configuration or environment variables for:

- Database credentials
- API keys and secrets
- Environment-specific infrastructure configuration
- Values required during application boot

In general:

- `.env` → infrastructure and secrets
- `config/*.php` → static application configuration
- `egough/laravel-settings` → runtime, database-driven configuration

---

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

[](#installation)

```
composer require egough/laravel-settings:^1.0
```

Publish configuration and migrations:

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

---

Application Settings
--------------------

[](#application-settings)

Global settings are accessible anywhere in your application.

### Helper

[](#helper)

```
settings()->set('site.name', 'My Application');

settings()->get('site.name');
```

### Facade

[](#facade)

```
use Settings;

Settings::set('site.name', 'My Application');
Settings::get('site.name');
```

### Dependency Injection

[](#dependency-injection)

```
use Egough\LaravelSettings\SettingsManager;

public function __construct(
    private SettingsManager $settings
) {}

$this->settings->get('site.name');
```

---

Model Settings
--------------

[](#model-settings)

Settings can be attached to any Eloquent model.

Add the trait:

```
use Egough\LaravelSettings\Traits\HasSettings;

class User extends Model
{
    use HasSettings;
}
```

Usage:

```
$user = User::find(1);

$user->settings()->set('ui.theme', 'dark');

$user->settings()->get('ui.theme');
```

Retrieve all settings:

```
$user->settings()->all();
```

Remove a setting:

```
$user->settings()->forget('ui.theme');
```

---

Feature Flags
-------------

[](#feature-flags)

Feature flags are boolean settings.

```
flag('billing.enabled');

Flag::enabled('billing.enabled');
```

With fallback:

```
flag('beta.feature', false);
```

---

Blade Directives
----------------

[](#blade-directives)

```
@hasSetting('site.name')
@endhasSetting

@hasFlag('billing.enabled')
@endhasFlag

@setting('site.name')
```

---

Default Values
--------------

[](#default-values)

Define defaults in `config/settings.php`:

```
'defaults' => [
    'site.name' => 'Laravel App',
];
```

Lookup order:

1. Database value
2. Config default
3. Provided fallback

---

Caching
-------

[](#caching)

Settings are cached automatically.

Clear cache manually:

```
php artisan settings:clear-cache
```

---

Testing
-------

[](#testing)

Install development dependencies:

```
composer install
```

Run the test suite:

```
composer test
```

Or run PHPUnit directly:

```
vendor/bin/phpunit
```

The package tests use a lightweight in-memory SQLite setup for repository integration coverage, so no external database service is required.

---

Artisan Commands
----------------

[](#artisan-commands)

```
php artisan settings:get site.name
php artisan settings:set site.name "My App"
php artisan settings:clear-cache
```

---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, 12, or 13

---

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance82

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

5

Last Release

97d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.3.1PHP ^8.2 || ^8.3 || ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/489ff16431bccb55fa9e5d7544f0d0d6a3b3fb32d80fb6a75ee1805036b5f589?d=identicon)[egough](/maintainers/egough)

---

Top Contributors

[![realedwardgough](https://avatars.githubusercontent.com/u/5840148?v=4)](https://github.com/realedwardgough "realedwardgough (13 commits)")

---

Tags

feature-flagslaravelphpsettingslaravelconfigurationSettingsfeature-flags

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M122](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9742.3M121](/packages/roots-acorn)[propaganistas/laravel-disposable-email

Disposable email validator

6012.9M7](/packages/propaganistas-laravel-disposable-email)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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