Looking to hire Laravel developers? Try LaraJobs

laravel-site-settings maintained by karjah

Description
Simple settings stored in the database.
Author
Last update
2026/04/22 21:19 (dev-main)
License
Links
Downloads
1

Comments
comments powered by Disqus

Site Settings for Laravel

A lightweight, headless key-value settings engine with automatic caching.

Installation

  1. Install via composer:
composer require karjah/laravel-site-settings
  1. Run the migrations:
php artisan migrate
  1. Publish the config:
php artisan vendor:publish --tag=site-settings-config

Usage

Using the Model

You can interact with the settings directly via the Setting model. This is recommended for better IDE support.

use Karjah\SiteSettings\Models\Setting;

// Set a value
Setting::set('site_name', 'My Awesome Site');

// Get a value
$name = Setting::get('site_name', 'Default Name');

Using the Helper

For quick access in Blade views or controllers, you can use the global helper function:

// Set multiple values
site_setting([
'contact_email' => 'admin@example.com',
'maintenance_mode' => 'off'
]);

// Get a value
{{ site_setting('site_name') }}

Retrieving Values

The first call fetches from the database and caches the results forever; subsequent calls hit the cache for high performance.

Cache Management

The cache is automatically cleared whenever you use the set() method or the helper to update a value. If you manually edit the database directly, run:

php artisan cache:forget site_settings

Config

Ths published config file is just for a simple place to put settings to load with config('site-settings.')

You may need to refresh the config if the values have been cached:

php artisan config:clear