PHPackages                             codersandip/laravel-dynamic-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. [Admin Panels](/categories/admin)
4. /
5. codersandip/laravel-dynamic-settings

ActiveLibrary[Admin Panels](/categories/admin)

codersandip/laravel-dynamic-settings
====================================

A professional Laravel package to store and manage application settings dynamically using the database with caching, multi-tenant support, and an admin panel UI.

v1.0.0(2mo ago)00MITBladePHP ^8.1CI failing

Since Mar 9Pushed 2mo agoCompare

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

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

Laravel Dynamic Settings Manager
================================

[](#laravel-dynamic-settings-manager)

[![Latest Version on Packagist](https://camo.githubusercontent.com/edd4734d0743fdaa0e2dea550ab05c915748534dc558e7ae9ab8ec3227d036ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64657273616e6469702f6c61726176656c2d64796e616d69632d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codersandip/laravel-dynamic-settings)[![PHP Version Require](https://camo.githubusercontent.com/e7a5a35f33b6dceee3370a0c085d714cdab4445bc3ed4bb906feb5ae4113a37b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f636f64657273616e6469702f6c61726176656c2d64796e616d69632d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codersandip/laravel-dynamic-settings)[![License](https://camo.githubusercontent.com/f21e6b53d21f7108aae48d527601150807f093602ebd2603607dadd3e6340c7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f64657273616e6469702f6c61726176656c2d64796e616d69632d73657474696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codersandip/laravel-dynamic-settings)

A professional Laravel package to store and manage application settings dynamically using the **database** instead of config files. Supports automatic caching, multi-tenant scoping, per-user overrides, and a beautiful admin panel UI.

---

Features
--------

[](#features)

- 📦 **Database-driven settings** — store any key/value with type casting
- ⚡ **Automatic caching** — configurable driver and TTL, cache invalidated on update
- 🏢 **Multi-tenant support** — tenant-scoped settings with global fallback
- 👤 **Per-user overrides** — priority: user → tenant → global
- 🎨 **Admin Panel UI** — dark-mode Bootstrap 5 CRUD interface with search, filter, toggles
- 🔄 **Inline editing** — AJAX quick-update widget on the edit page
- 🛡️ **Type support** — `string`, `integer`, `float`, `boolean`, `json`
- 🖥️ **Artisan commands** — `settings:cache`, `settings:clear`, `settings:seed`
- ✅ **Fully tested** — PHPUnit test suite included

---

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

[](#requirements)

- PHP **8.1+**
- Laravel **10.x / 11.x / 12.x**

---

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

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require codersandip/laravel-dynamic-settings
```

> Laravel auto-discovers the service provider. No manual registration needed.

### 2. Publish assets

[](#2-publish-assets)

Publish everything at once:

```
php artisan vendor:publish --tag=settings-all
```

Or selectively:

```
# Config only
php artisan vendor:publish --tag=settings-config

# Migrations only
php artisan vendor:publish --tag=settings-migrations

# Views only
php artisan vendor:publish --tag=settings-views

# Routes only
php artisan vendor:publish --tag=settings-routes
```

### 3. Run migrations

[](#3-run-migrations)

```
php artisan migrate
```

### 4. (Optional) Seed default settings

[](#4-optional-seed-default-settings)

```
php artisan settings:seed
```

---

Configuration
-------------

[](#configuration)

After publishing, edit `config/settings.php`:

```
return [
    // Cache driver (file, redis, memcached, array)
    'cache_driver' => env('SETTINGS_CACHE_DRIVER', 'file'),

    // Cache TTL in seconds (3600 = 1 hour)
    'cache_ttl' => env('SETTINGS_CACHE_TTL', 3600),

    // Cache key prefix
    'cache_prefix' => env('SETTINGS_CACHE_PREFIX', 'dyn_setting'),

    // Admin panel URL prefix
    'route_prefix' => env('SETTINGS_ROUTE_PREFIX', 'admin/settings'),

    // Middleware applied to admin routes
    'route_middleware' => ['web', 'auth'],

    // Available groups in the dropdown
    'groups' => ['general', 'email', 'payment', 'security'],
];
```

You can also set these in your `.env` file:

```
SETTINGS_CACHE_DRIVER=redis
SETTINGS_CACHE_TTL=7200
SETTINGS_ROUTE_PREFIX=dashboard/settings
```

---

Usage
-----

[](#usage)

### Helper Function

[](#helper-function)

```
// Get a setting
setting('site_name');                     // → 'My Application'

// Get with a default value
setting('site_name', 'Default App');      // → 'Default App' if not set

// Get with tenant context (falls back to global if not found)
setting('currency', 'USD', $tenantId);

// Get with tenant + user context
setting('theme', 'light', $tenantId, $userId);
```

### Set a Setting

[](#set-a-setting)

```
// Via helper (chained)
setting()->set('site_name', 'My App');

// With options
setting()->set('page_size', 20, [
    'type'        => 'integer',
    'group'       => 'general',
    'description' => 'Results per page',
]);
```

### Facade

[](#facade)

```
use Codersandip\DynamicSettings\Facades\Settings;

Settings::get('site_name');
Settings::get('site_name', 'Default');
Settings::set('site_name', 'New Name');
Settings::delete('site_name');
Settings::has('site_name');
```

### Service (Dependency Injection)

[](#service-dependency-injection)

```
use Codersandip\DynamicSettings\Services\SettingsService;

class MyController extends Controller
{
    public function __construct(private SettingsService $settings) {}

    public function index()
    {
        $siteName = $this->settings->get('site_name', 'My App');
        // ...
    }
}
```

---

Data Types
----------

[](#data-types)

TypePHP TypeStorageExample`string``string`As-is`"Hello World"``integer``int`Numeric string`42``float``float`Numeric string`3.14``boolean``bool``"1"` / `"0"``true` / `false``json``array`JSON string`["stripe", "paypal"]````
setting()->set('enabled',  true,             ['type' => 'boolean']);
setting()->set('count',    100,              ['type' => 'integer']);
setting()->set('gateways', ['stripe', 'pp'], ['type' => 'json']);

setting('enabled');   // → true  (bool)
setting('count');     // → 100   (int)
setting('gateways');  // → ['stripe', 'pp']  (array)
```

---

Multi-Tenant Support
--------------------

[](#multi-tenant-support)

Settings resolve with this priority: **user → tenant → global**

```
// Store global setting
setting()->set('currency', 'USD');

// Store tenant-specific override
setting()->set('currency', 'GBP', ['tenant_id' => 5]);

// Store user-specific override (within a tenant)
setting()->set('currency', 'EUR', ['tenant_id' => 5, 'user_id' => 12]);

// Retrieval
setting('currency');              // → 'USD'  (global)
setting('currency', null, 5);    // → 'GBP'  (tenant 5 override)
setting('currency', null, 5, 12);// → 'EUR'  (user 12 override)
setting('currency', null, 5, 99);// → 'GBP'  (user 99 falls back to tenant)
setting('currency', null, 9);    // → 'USD'  (tenant 9 falls back to global)
```

### Fluent API

[](#fluent-api)

```
use Codersandip\DynamicSettings\Facades\Settings;

// Set tenant context once
$tenantSettings = Settings::forTenant(5);

$tenantSettings->get('currency');    // uses tenant 5
$tenantSettings->get('locale');

// Chain tenant + user
Settings::forTenant(5)->forUser(12)->get('theme');
```

---

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

[](#artisan-commands)

CommandDescription`settings:cache`Pre-warm cache with all settings from DB`settings:clear`Flush the settings cache`settings:seed`Seed a set of default settings```
php artisan settings:cache
php artisan settings:clear
php artisan settings:seed
php artisan settings:seed --force   # overwrite existing settings
```

---

Admin Panel
-----------

[](#admin-panel)

Access the admin panel at `/admin/settings` (configurable via `route_prefix`).

The panel includes:

- 📋 **Index** — list all settings with search, group/type filter, boolean toggles
- ➕ **Create** — add a new setting with type, group, scope options
- ✏️ **Edit** — update a setting, with inline AJAX quick-update widget
- 🗑️ **Delete** — remove a setting (with confirmation)

### Protecting the Admin Panel

[](#protecting-the-admin-panel)

Set the middleware in `config/settings.php`:

```
'route_middleware' => ['web', 'auth', 'can:manage-settings'],
```

Or disable the built-in routes and define your own:

```
// config/settings.php
'disable_routes' => true,
```

Then publish routes:

```
php artisan vendor:publish --tag=settings-routes
```

And register the file in `bootstrap/app.php` or `routes/web.php`.

---

Database Schema
---------------

[](#database-schema)

```
settings
├── id                  (bigint, auto-increment)
├── key                 (varchar 191, indexed)
├── value               (longtext, nullable)
├── type                (varchar 20 — string|integer|float|boolean|json)
├── group               (varchar 50, indexed, default: general)
├── tenant_id           (bigint unsigned, nullable, indexed)
├── user_id             (bigint unsigned, nullable, indexed)
├── description         (varchar, nullable)
├── is_public           (boolean, default: false)
├── created_at
└── updated_at

UNIQUE (key, tenant_id, user_id)

```

---

Testing
-------

[](#testing)

```
composer test
```

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

---

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

---

Author
------

[](#author)

**Sandip** —
GitHub: [github.com/codersandip](https://github.com/codersandip)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance87

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

63d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/156ff476b46c2fdcf56b1ea2dd94a891f78c538b1e8243774219ff08a81aa236?d=identicon)[codersandip](/maintainers/codersandip)

---

Top Contributors

[![tushar-sandip](https://avatars.githubusercontent.com/u/99278791?v=4)](https://github.com/tushar-sandip "tushar-sandip (1 commits)")

---

Tags

laravelconfigurationSettingsmulti-tenantadmin-paneldynamic-settings

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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