- 数据库存储 / Database persistent
- Laravel 框架自带缓存 / Cache by Laravel framework
- 运行时缓存 / Runtime cache (Get from cache or db one time during Request Lifecycle)
Via Composer
$ composer require xtrees/lara-setting
$ php artisan vendor:publish --tag=config
$ php artisan vendor:publish --tag=migrations
$ php artisan migrate
return [
//Use framework's cache drive
'cache' => [
'mode' => 'batch',
'enable' => true,
'prefix' => 'settings:',
//cache time .minutes
'ttl' => 60,
],
//Facade name LaraSetting::get(..)
'facade' => 'LaraSetting',
];
//Helper funtion
settings('group.key')
//Create or update setting in DB/cache/runtime
LaraSetting::set('group.key', 'setting-value');
//Get the setting from runtime/cache/DB
LaraSetting::get('group.key');
//Remove setting
LaraSetting::forget('group.key');
The MIT License (MIT). Please see License File for more information.