centrex/laravel-settings

Manage settings in laravel

Maintainers

Package info

github.com/centrex/laravel-settings

pkg:composer/centrex/laravel-settings

Statistics

Installs: 2 544

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v1.3.2 2025-07-17 07:02 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Database-backed application settings with a caching layer, Laravel config integration, and convenient helper functions. Settings are stored in a settings table and cached forever until changed.

Installation

composer require centrex/laravel-settings
php artisan vendor:publish --tag="laravel-settings-migrations"
php artisan migrate

Usage

Via helper functions

// Get a setting (with optional default)
settings('site.name', 'My App');
get_setting('site.name', 'My App');

// Set a setting
set_setting('site.name', 'Acme Corp');

// Check existence
setting_exists('site.name');  // true

// Remove a setting
remove_setting('site.name');

// Get the Settings service instance
$settingsService = settings();

Via facade

use Centrex\Settings\Facades\Settings;

Settings::set('maintenance.enabled', true);
Settings::get('maintenance.enabled', false);
Settings::has('maintenance.enabled');
Settings::forget('maintenance.enabled');

// Force a cache refresh
Settings::refreshCache();

Config integration

Settings are merged into the Laravel config on boot via chargeConfig(). After that, database settings are accessible through config():

config('site.name');  // returns the value stored in the settings table

Caching

  • Reads use Cache::rememberForever per key.
  • Any set() or forget() call automatically flushes the cache and reloads config.

Testing

composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.