centrex / laravel-settings
Manage settings in laravel
v1.3.2
2025-07-17 07:02 UTC
Requires
- php: ^8.2|^8.3|^8.4
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.5
- orchestra/testbench: ^9.5
- pestphp/pest: ^3.4
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- rector/rector: ^1.2
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2026-04-28 02:27:14 UTC
README
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::rememberForeverper key. - Any
set()orforget()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.