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

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

teknyo/laravel-settings-manager
===============================

Easily manage app settings stored in DB or JSON file

00PHP

Since Nov 1Pushed 6mo agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

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

[](#laravel-settings-manager)

[![Latest Version](https://camo.githubusercontent.com/34e695c6016bc2a934a96bed696e29b2f2ab562a7134d65a55d00653cd506bea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c75652e737667)](https://github.com/yourvendor/laravel-settings)[![PHP Version](https://camo.githubusercontent.com/5c9ed36807c6dd9d199e222d90b70b33a8073a27d76a4fca70cf5cc460ec0650/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d707572706c652e737667)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/552ea80ea7c6f1343f4a9d615105686241f5cb554891af2271f54aa4305d0ce9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531302e3025374325354531312e302d7265642e737667)](https://laravel.com)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)

A simple, elegant, and powerful settings manager for Laravel applications. Store and retrieve application settings from database or JSON file with built-in caching support.

✨ Features
----------

[](#-features)

- 🗄️ **Multiple Storage Drivers**: Database or JSON file storage
- ⚡ **Built-in Caching**: Automatic caching layer for performance
- 🔄 **Automatic Serialization**: Store arrays, objects, and primitives
- 🎨 **Clean API**: Simple and intuitive `Setting::get()` and `Setting::set()` methods
- 🛠️ **Artisan Commands**: Manage settings from command line
- 📦 **Batch Operations**: Set or delete multiple settings at once
- 🔒 **Type-Safe**: Full type hints and return types
- 🚀 **Laravel 10 &amp; 11**: Compatible with latest Laravel versions

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.x or 11.x

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require yourvendor/laravel-settings
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file:

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

### Setup Database Driver

[](#setup-database-driver)

If using the database driver, publish and run migrations:

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

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file will be published to `config/settings.php`:

```
return [
    // Storage driver: 'database' or 'json'
    'driver' => env('SETTINGS_DRIVER', 'database'),

    // Database driver settings
    'database' => [
        'connection' => env('DB_CONNECTION', 'mysql'),
        'table' => 'settings',
    ],

    // JSON driver settings
    'json' => [
        'path' => 'app/settings.json',
    ],

    // Cache settings
    'cache' => [
        'enabled' => true,
        'store' => env('CACHE_DRIVER', 'file'),
        'prefix' => 'settings',
    ],
];
```

### Environment Variables

[](#environment-variables)

Add to your `.env` file:

```
SETTINGS_DRIVER=database  # or 'json'
```

🚀 Usage
-------

[](#-usage)

### Basic Operations

[](#basic-operations)

```
use YourVendor\Settings\Facades\Setting;

// Set a setting
Setting::set('site_name', 'My Awesome Website');
Setting::set('timezone', 'Asia/Colombo');
Setting::set('maintenance_mode', false);

// Get a setting
$siteName = Setting::get('site_name');
// Returns: 'My Awesome Website'

// Get with default value
$theme = Setting::get('theme', 'light');
// Returns: 'light' if 'theme' doesn't exist

// Check if setting exists
if (Setting::has('site_name')) {
    echo 'Site name is configured';
}

// Delete a setting
Setting::forget('old_setting');
```

### Working with Arrays and Objects

[](#working-with-arrays-and-objects)

The package automatically serializes complex data types:

```
// Store arrays
Setting::set('features', [
    'dark_mode' => true,
    'api_enabled' => false,
    'max_upload_size' => 10,
]);

// Retrieve arrays
$features = Setting::get('features');
// Returns: ['dark_mode' => true, 'api_enabled' => false, 'max_upload_size' => 10]

// Store objects
Setting::set('email_config', [
    'driver' => 'smtp',
    'host' => 'smtp.mailtrap.io',
    'port' => 587,
]);
```

### Batch Operations

[](#batch-operations)

```
// Set multiple settings at once
Setting::setMany([
    'app_name' => 'MyApp',
    'app_version' => '1.0.0',
    'maintenance_mode' => false,
    'items_per_page' => 20,
]);

// Delete multiple settings
Setting::forgetMany(['temp_key1', 'temp_key2', 'cache_key']);

// Get all settings
$allSettings = Setting::all();
// Returns: ['site_name' => 'My Site', 'timezone' => 'UTC', ...]

// Clear all settings (use with caution!)
Setting::clear();
```

🎯 Artisan Commands
------------------

[](#-artisan-commands)

Manage settings from the command line:

### Get a Setting

[](#get-a-setting)

```
php artisan setting:get site_name
# Output: Value for 'site_name': "My Awesome Website"

# With default value
php artisan setting:get theme --default=light
```

### Set a Setting

[](#set-a-setting)

```
# Simple value
php artisan setting:set site_name "My New Site Name"

# Boolean
php artisan setting:set maintenance_mode false

# JSON value
php artisan setting:set features '{"dark_mode":true,"notifications":false}'

# Number
php artisan setting:set max_users 1000
```

### List All Settings

[](#list-all-settings)

```
php artisan setting:list
```

Output:

```
+-------------------+--------------------------------+
| Key               | Value                          |
+-------------------+--------------------------------+
| site_name         | "My Awesome Website"           |
| timezone          | "Asia/Colombo"                 |
| maintenance_mode  | false                          |
| features          | {"dark_mode":true}             |
+-------------------+--------------------------------+

```

### Clear All Settings

[](#clear-all-settings)

```
php artisan setting:clear

# Skip confirmation
php artisan setting:clear --force
```

💡 Real-World Examples
---------------------

[](#-real-world-examples)

### Application Configuration

[](#application-configuration)

```
// In your AppServiceProvider
public function boot()
{
    config(['app.timezone' => Setting::get('timezone', 'UTC')]);
    config(['app.name' => Setting::get('site_name', 'Laravel')]);
}
```

### Feature Flags

[](#feature-flags)

```
if (Setting::get('features.new_dashboard', false)) {
    return view('dashboard.new');
}
return view('dashboard.old');
```

### Maintenance Mode

[](#maintenance-mode)

```
// Middleware
public function handle($request, Closure $next)
{
    if (Setting::get('maintenance_mode', false)) {
        return response()->view('maintenance', [], 503);
    }
    return $next($request);
}
```

### User Preferences

[](#user-preferences)

```
class UserSettingsController
{
    public function update(Request $request)
    {
        $userId = auth()->id();

        Setting::setMany([
            "user.{$userId}.theme" => $request->theme,
            "user.{$userId}.language" => $request->language,
            "user.{$userId}.notifications" => $request->notifications,
        ]);

        return back()->with('success', 'Settings updated!');
    }
}
```

### API Rate Limiting

[](#api-rate-limiting)

```
$rateLimit = Setting::get('api.rate_limit', 60);
$rateLimitWindow = Setting::get('api.rate_limit_window', 1);

RateLimiter::for('api', function (Request $request) use ($rateLimit, $rateLimitWindow) {
    return Limit::perMinutes($rateLimitWindow, $rateLimit);
});
```

🔧 Advanced Usage
----------------

[](#-advanced-usage)

### Custom Storage Location (JSON Driver)

[](#custom-storage-location-json-driver)

```
// config/settings.php
'json' => [
    'path' => 'custom/path/settings.json',
],
```

### Disable Caching

[](#disable-caching)

```
// config/settings.php
'cache' => [
    'enabled' => false,
],
```

### Custom Cache Store

[](#custom-cache-store)

```
// config/settings.php
'cache' => [
    'enabled' => true,
    'store' => 'redis', // Use Redis for caching
    'prefix' => 'app_settings',
],
```

### Multiple Database Connections

[](#multiple-database-connections)

```
// config/settings.php
'database' => [
    'connection' => 'settings_db', // Use separate connection
    'table' => 'app_settings',
],
```

🏗️ Architecture
---------------

[](#️-architecture)

### Storage Drivers

[](#storage-drivers)

**Database Driver**: Stores settings in a database table with automatic JSON serialization.

**JSON Driver**: Stores settings in a JSON file with file locking for concurrent access.

### Caching Layer

[](#caching-layer)

The `CachedRepository` wraps any storage driver and provides transparent caching:

- Cache hits avoid database/file queries
- Automatic cache invalidation on updates
- Configurable TTL (default: 1 hour)
- Supports any Laravel cache driver

📊 Performance
-------------

[](#-performance)

- **Caching**: First access queries storage, subsequent accesses use cache
- **Batch Operations**: Use `setMany()` for multiple settings (single transaction)
- **JSON Driver**: Single file read loads all settings into memory
- **Database Driver**: Indexed key column for fast lookups

📝 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

🐛 Support
---------

[](#-support)

If you discover any security vulnerabilities or bugs, please email .

For general questions and support, please open an issue on GitHub.

📚 Changelog
-----------

[](#-changelog)

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

🗺️ Roadmap
----------

[](#️-roadmap)

- Setting groups/namespaces
- Setting validation rules
- Web UI for managing settings
- Import/Export functionality
- Setting encryption for sensitive data
- Audit log for setting changes
- Setting versioning/history

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance47

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e5a7da0a74681757bcfa19233cc63a581a5aa3c4a6bc422de51a07ba394db30?d=identicon)[teknyo](/maintainers/teknyo)

---

Top Contributors

[![sketchspintech](https://avatars.githubusercontent.com/u/88823633?v=4)](https://github.com/sketchspintech "sketchspintech (1 commits)")

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/graphviz

Wrapper for Graphviz

9611.3M21](/packages/phpdocumentor-graphviz)[beberlei/composer-monorepo-plugin

312503.1k](/packages/beberlei-composer-monorepo-plugin)[stephenjude/filament-feature-flags

Filament implementation of feature flags and segmentation with Laravel Pennant.

118126.9k](/packages/stephenjude-filament-feature-flags)[brotkrueml/schema

Embedding schema.org vocabulary - API and view helpers for schema.org markup

33584.6k13](/packages/brotkrueml-schema)[eduarguz/shift-php-cs

PHP CS Fixer - Laravel Coding Style Ruleset

1145.5k29](/packages/eduarguz-shift-php-cs)

PHPackages © 2026

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