Easy management of your application settings with Setting Pro
Published on by Eric L. Barnes
Laravel Setting Pro is a package that provides a simple and effective way to handle your application settings with support for persistent storage using either file-based or database drivers.
Setting Pro Usage
You can use the package two ways:
setting
function:
Using the // Get a setting value$value = setting('my_setting')->get('key', 'default value');//or$value = setting('my_setting','key', 'default value');//or$value = setting()->select('my_setting')->get('key', 'default value'); // Set a setting valuesetting('my_setting')->set(['key' => 'value']);//orsetting()->select('my_setting')->set(['key' => 'value']); //delete a key from settingsetting('my_setting')->delete('key');//orsetting()->select('my_setting')->delete('key');
Setting
facade:
Using the <?phpuse Sajadsdi\LaravelSettingPro\Support\Setting; // Get a setting value$value = Setting::select('my_setting')->get('key', 'default value');//or$value = Setting::my_setting()->get('key', 'default value');//or$value = Setting::my_setting('key', 'default value'); // Set a setting valueSetting::select('my_setting')->set('key', 'value');//orSetting::my_setting()->set('key', 'value'); //delete key from settingSetting::select('my_setting')->delete('key');//orSetting::my_setting()->delete('key'); //checking exists by has methodif(Setting::select('my_setting')->has('key')){ echo "key exists!";}else{ echo "key not exists!";}
Setting Pro Features Include
-
Flexible Storage: Choose between file-based or database storage to suit your application's needs.
-
Flexible Database: Choose between
mysql
ormongodb
or create own db connection for settings. -
Caching: Improve performance with automatic caching of settings. You can choose between
file
orredis
or create own cache driver. -
Queue Support: Handle setting updates and deletes in the background, ensuring smooth user experiences.
-
Event Triggers: Respond to setting changes in real-time by leveraging Laravel events.
-
Global Helper Function & Facade: Access and manipulate settings anywhere in your laravel app with a simple
setting
function orSetting
facade (even in the config files). -
Artisan Commands for Ease of Use: Publish configuration and migrations effortlessly with the
setting:publish
artisan command; complete installations, migrations, and initial tests using thesetting:install
command. -
Easy get & set and delete settings with dot notation:
get
&set
&delete
andhas
operations on nested settings keys. -
Easy import settings : Import settings from a driver to default store driver.
-
Auto create setting : you can use default value for get operation or set operation on any new setting name.
Read more
Visit the GitHub repo for installation instructions and for more information on how to use the package.
Eric is the creator of Laravel News and has been covering Laravel since 2012.