centrex/laravel-settings

Manage settings in laravel
3,795
Install
composer require centrex/laravel-settings
Latest Version:v1.5.0
PHP:^8.3
License:MIT
Last Updated:Sep 30, 2026
Links: GitHub  ·  Packagist
Maintainer: rochi88

Manage settings in Laravel

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.

Related Packages

Version History

Version Released PHP Laravel License
v1.5.0 ^8.3 ^11.0|^12.0|^13.0 MIT
v1.4.0 ^8.3 ^11.0|^12.0|^13.0 MIT
v1.3.2 ^8.2|^8.3|^8.4 ^10.0|^11.0|^12.0 MIT
v1.3.1 ^8.2|^8.3|^8.4 ^10.0|^11.0|^12.0 MIT
v1.3.0 ^8.2|^8.3|^8.4 ^10.0|^11.0|^12.0 MIT