elegantly/laravel-settings
Settings for your Laravel App
3,754
9
| Install | |
|---|---|
composer require elegantly/laravel-settings |
|
| Latest Version: | v1.2.1 |
| PHP: | ^8.3 |
| Laravel: | 11 · 12 · 13 |
| License: | MIT |
| Last Updated: | Aug 15, 2026 |
| Links: | GitHub · Packagist |
Maintainer: QuentinGab
Elegant Global Settings Management in Laravel
A simple and flexible way to manage global or model-specific settings in your Laravel app.
Features
- Define global settings
- Store settings in the database via Eloquent
- Cache settings for performance
- Attach settings to users or any other model
- Support for typed namespaced settings classes
Table of Contents
Installation
Install the package via Composer:
composer require elegantly/laravel-settings
Publish the migration and run it:
php artisan vendor:publish --tag="settings-migrations"
php artisan migrate
Optionally, publish the configuration file:
php artisan vendor:publish --tag="settings-config"
Configuration
Published config file (config/settings.php):
use Elegantly\Settings\Models\Setting;
return [
/*
* The Eloquent model used to store and retrieve settings
*/
'model' => Setting::class,
/*
* Cache configuration for global settings
*/
'cache' => [
'enabled' => true,
'key' => 'settings',
'ttl' => 60 * 60 * 24, // 1 day
],
];
Usage
Basic Usage (Facade)
use Elegantly\Settings\Facades\Settings;
// Set a value
Settings::set(
namespace: 'home',
name: 'color',
value: 'white'
);
// Get a value
$setting = Settings::get(
namespace: 'home',
name: 'color'
);
$setting->value; // white
Dependency Injection
namespace App\Http\Controllers;
use Elegantly\Settings\Settings;
class UserController extends Controller
{
public function index(Settings $settings)
{
$settings->set(
namespace: 'home',
name: 'color',
value: 'white'
);
$setting = $settings->get(
namespace: 'home',
name: 'color'
);
$setting->value; // white
}
}
Typed Namespaced Settings
For better DX, define custom typed settings classes:
Usage
namespace App\Http\Controllers;
use App\Settings\HomeSettings;
class UserController extends Controller
{
public function index(HomeSettings $settings)
{
$settings->color; // white
$settings->color = 'black';
$settings->save();
}
}
Defining a Typed Settings Class
namespace App\Settings;
use Elegantly\Settings\NamespacedSettings;
class HomeSettings extends NamespacedSettings
{
public ?string $color = null;
/** @var int[] */
public array $articles = [];
public static function getNamespace(): string
{
return 'home';
}
}
Testing
Run the test suite:
composer test
Changelog
See CHANGELOG for details on recent changes.
Contributing
See CONTRIBUTING for contribution guidelines.
Security Vulnerabilities
Please review our security policy for reporting vulnerabilities.
Credits
License
This package is open-sourced under the MIT license.
Related Packages
hadyfayed/siren
Laravel KickStart
9
0
filament
filament-shield
filament-spatie-laravel-backup
filament-spatie-laravel-health
hadyfayed
hotwire
jetstream
laravel
laravel-settings
laravel-sluggable
livewire
siren
spatie
spatie-laravel-media-library-plugin
spatie-laravel-settings-plugin
spatie-laravel-tags-plugin
spatie-laravel-translatable-plugin
turbo-laravel
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.2.1 | ^8.3 | ^11.0| | MIT | |
| v1.2.0 | ^8.3 | ^11.0| | MIT | |
| v1.1.0 | ^8.3 | ^11.0| | MIT | |
| v1.0.0 | ^8.3 | ^11.0| | MIT |