karjah/laravel-site-settings

Simple settings stored in the database.

Maintainers

Package info

github.com/karjah/laravel-site-settings

pkg:composer/karjah/laravel-site-settings

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-22 19:19 UTC

This package is auto-updated.

Last update: 2026-04-22 19:22:42 UTC


README

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