1. Go to this page and download the library: Download webafra/larasettings library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Webafra\LaraSetting\Facade\Setting;
// Store a value
Setting::set('site_name', 'My Website');
// Retrieve a value (with optional default)
$name = Setting::get('site_name', 'Default Name');
// Check if a setting exists
if (Setting::has('site_name')) {
// ...
}
// Delete a setting
Setting::delete('site_name');
// Store in a specific group
Setting::set('color', '#ffffff', false, 'theme');
Setting::set('font', 'Inter', false, 'theme');
// Retrieve from a group
$color = Setting::get('color', '#000000', 'theme');
// Get all settings in a group as key-value array
$theme = Setting::getGroup('theme');
// ['color' => '#ffffff', 'font' => 'Inter']
// Mark as primary when storing
Setting::set('app_name', 'My App', true);
// Store multiple primaries (arrays are auto JSON-encoded)
Setting::storePrimary([
'app_name' => 'My App',
'social_links' => ['twitter' => 'https://...'],
]);
// Retrieve all primary settings as key-value array
$primaries = Setting::getPrimary();
// Store multiple settings at once (optionally in a group)
Setting::store([
'key1' => 'value1',
'key2' => 'value2',
], 'my_group');