elipzis/laravel-simple-setting
A lightweight Laravel package for managing simple application settings as key-value pairs, with helpers to store, retrieve, and update persisted configuration values. Ideal for small dynamic settings without a full CMS.
composer require elipzis/laravel-simple-setting then publish and run the migration:
php artisan vendor:publish --tag=setting-migration # or --provider="ElipZis\Setting\SettingServiceProvider"
php artisan migrate
Publishing the config (config/setting.php) is worth doing up front so table name, model binding and caching options are explicit in your repo rather than package defaults.settings table of key/value pairs for site-wide toggles and editable copy — maintenance banners, feature flags, contact details, default pagination size — read through the Setting facade:
use ElipZis\Setting\Facades\Setting;
Setting::set('site.maintenance', true);
Setting::get('site.maintenance', false); // second arg as default
Setting::has('site.maintenance');
Setting model. The stored value column type and any casting behaviour determine how you'll handle booleans, arrays and numbers, and that shapes everything downstream.billing.currency, mail.from_address, features.new_checkout) and use a small Settings wrapper class or enum of known keys so typos don't silently return defaults.App\Support\Settings class with typed accessors (bool(), int(), array()) keeps the package dependency in one place and gives you a migration path off it later.
class Settings
{
public static function bool(string $key, bool $default = false): bool
{
return filter_var(Setting::get($key, $default), FILTER_VALIDATE_BOOL);
}
}
Setting::set() lazily on first read races under concurrency and pollutes the table with half-configured rows. Put initial values in a SettingSeeder and only read with defaults in application code.Setting::set() — a hidden input in an admin form shouldn't be able to overwrite billing.secret. Validate against your known-key enum, then write in a loop.Cache::rememberForever() keyed per setting and clear on write. If the package itself offers caching in config/setting.php, enable it, but verify it is invalidated on set()/remove() before trusting it.register() will break on a fresh install (no table yet) and during migrate. Read them in boot() and guard with Schema::hasTable('settings') or a try/catch if you must touch them early.RefreshDatabase and seed the settings your test needs in setUp(). Since reads are cached, call Cache::flush() in tearDown() or per test, otherwise leakage between tests produces confusing failures.tenant.{id}.feature) rather than schema changes; a tenant_id column would require forking the model and migration."elipzis/laravel-simple-setting": "^1.2" and skip v1.3.0 entirely — there is nothing to gain from the upgrade other than the framework bump. Check composer.json in the release to confirm the exact constraints before upgrading in a shared codebase.settings table, the package (and your wrapper cache) will keep serving stale values. Treat Setting::set()/remove() as the only write path, or add an explicit cache-bust hook.null vs false vs "0". The value column is typically a string column, so Setting::get('flag', false) can return the string "0", which is truthy in a naive if. Always cast on read; the typed wrapper above is not optional if you store booleans.json_encode on write and json_decode on read, or don't store them at all. Mixed conventions across a team lead to values that decode for one key and not another.value is a VARCHAR(255), long JSON blobs, HTML snippets or API keys will silently truncate (or throw, depending on strict mode). Publish and adjust the migration to text early — altering it later on a large table is annoying.php artisan config:cache freezes the config values, so changing the table name via env at deploy time requires a cache clear. Same for any cache TTL settings.Setting::remove() removes the row; subsequent get($key, $default) returns your default, which may differ from the value the app ran with before. Fine, but be deliberate about it in migrations of settings.Setting model and using the package only for the storage/migration than trying to extend its internals — especially given the release cadence here is dependabot-driven.How can I help you explore Laravel packages today?