Download the PHP package shopapps/laravel-settings without Composer
On this page you can find all versions of the php package shopapps/laravel-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shopapps/laravel-settings
More information about shopapps/laravel-settings
Files in shopapps/laravel-settings
Package laravel-settings
Short Description config style settings but stored in a DB
License MIT
Homepage https://github.com/shopapps/laravel-settings
Informations about the package laravel-settings
Laravel Settings
Store and retrieve application settings from the database with built-in caching and an optional FilamentPHP admin panel.
Settings work like Laravel's config() helper — use dot-notation keys, store any type (strings, booleans, arrays, JSON), and scope settings globally or per-user. A pre-cache system loads all settings into memory in a single read for near-zero latency.
Requirements
- PHP 8.1+
- Laravel 9, 10, or 11
- FilamentPHP 3.x (optional, for the admin panel)
Installation
Publish and run the migration:
Optionally publish the config file:
This creates config/laravel-settings.php where you can customise caching, access control, and table options.
Quick Start
Usage
Reading Settings — setting()
Dot-notation keys are fully supported. If you store an array under the key notifications, you can access nested values:
Writing Settings — setting_add()
The type is auto-detected when omitted, but you can be explicit: string, boolean, integer, float, array, object.
Deleting Settings — setting_delete()
Clearing Cache — setting_clear_cache()
Service Class
All helpers delegate to SettingService. You can use it directly:
Deprecated Aliases
These function names still work but will be removed in a future major version:
| Deprecated | Use Instead |
|---|---|
add_setting() |
setting_add() |
delete_setting() |
setting_delete() |
clear_settings() |
setting_clear_cache() |
Caching
Laravel Settings has two caching layers that work together:
Per-Key Cache (enabled by default)
Each setting is individually cached on first read. Fast for small numbers of settings, but each key is a separate cache call.
Pre-Cache (recommended for production)
All database settings are loaded into a single cache entry and held in memory for the remainder of the request. This is similar to how php artisan config:cache works — one read, then pure PHP array lookups.
How It Works
- On the first
setting()call, the blob is loaded from the cache store into a static property (one I/O operation). - All subsequent calls read from the in-memory array — no cache or database calls.
- The blob is authoritative: if a key isn't found in the blob, the default is returned immediately without falling through to the database.
- When you
setting_add()orsetting_delete(), the blob is updated in-place and persisted — no full rebuild needed.
Performance
| Scenario | Typical Latency |
|---|---|
| No cache (direct DB query) | 15–30 ms |
| Per-key cache hit | 1–5 ms |
| Pre-cache — first call (loads blob) | < 0.01 ms |
| Pre-cache — subsequent calls (in-memory) | < 0.005 ms |
Artisan Commands
Build or clear the pre-cache from the command line:
Add php artisan settings:cache to your deployment script alongside config:cache and route:cache:
Filament Admin Panel
The package ships with a FilamentPHP resource for managing settings through the admin panel.
Setup
Register the plugin in your panel provider:
Settings Table
The resource displays all settings in a searchable, filterable table with columns for key, value, type, and user scope.
Cache Management Actions
A ⋮ Cache dropdown in the page header provides four actions:
| Action | Description |
|---|---|
| View Cache | Opens a read-only modal showing all pre-cached key/value pairs |
| Build Cache | Loads all DB settings into the pre-cache blob |
| Clear Pre-Cache | Removes the pre-cache blob only; per-key caches remain |
| Clear All Cache | Removes everything — pre-cache blob and all per-key caches |
Test Setting Action
Each row in the settings table has a ▶ Test button that reads the setting via the setting() helper and displays:
- Key — the setting's key
- Type — the stored type (string, boolean, array, etc.)
- Source — whether the value was served from
pre-cacheorper-key cache / DB - Time — retrieval time in milliseconds, colour-coded: 🟢 < 1 ms, 🟡 < 10 ms, 🔴 ≥ 10 ms
- Value — the resolved value (arrays shown as formatted JSON)
This is useful for verifying that caching is working and diagnosing performance.
Configuration
All options can be set via environment variables or in config/laravel-settings.php:
Caching
| Key | Env Variable | Default | Description |
|---|---|---|---|
cache_settings |
LARAVEL_SETTINGS_CACHE |
true |
Enable per-key caching |
cache_ttl |
LARAVEL_SETTINGS_CACHE_TTL |
86400 |
Per-key cache TTL (seconds) |
pre_cache_settings |
LARAVEL_SETTINGS_PRE_CACHE |
true |
Enable pre-cache blob |
pre_cache_ttl |
LARAVEL_SETTINGS_PRE_CACHE_TTL |
86400 |
Pre-cache blob TTL (seconds) |
Access Control
Restrict who can access the Filament resource:
Display
| Key | Env Variable | Default | Description |
|---|---|---|---|
edit_mode |
LARAVEL_SETTINGS_EDIT_MODE |
text |
Array editing mode: text (textarea) or simple (key-value fields) |
scope_to_tenant |
— | true |
Scope settings to the current Filament tenant |
navigation_section_group |
— | Settings |
Navigation group label |
Contributing
Feel free to submit pull requests or create issues for bug fixes and new features.
License
This package is open-sourced software licensed under the MIT license.
All versions of laravel-settings with dependencies
filament/filament Version ^5.0|^6.0
illuminate/support Version ^11.28|^12.0|^13.0
spatie/laravel-package-tools Version ^1.0|^2.0