swp/settings-bundle
SWP Settings Bundle provides flexible, database-backed application settings for Symfony. Define and organize settings, read and write values at runtime, and manage configuration through a clean service API, with caching to keep lookups fast.
The first thing a Laravel developer needs to internalise: swp/settings-bundle is a Symfony bundle, not a Laravel package. composer require swp/settings-bundle inside a Laravel app will drag in Symfony components and expect a container that Laravel never boots. There is no service provider, no facade, no config/settings.php in Laravel's shape. So "getting started" from a Laravel seat means one of two things:
If you are in Symfony (the intended environment):
composer require swp/settings-bundleAppKernel::registerBundles() (or config/bundles.php on Symfony 4+).If you are in Laravel: do not install it. Treat it as a spec. The useful first use case it demonstrates is storing site-wide or per-namespace configuration (site name, feature toggles, editor defaults) that editors change without a deploy.
Where to look first in the repo: the bundle's Entity/, Repository/, and Manager/ (or Service/) directories, plus the DI extension class — that reveals the service IDs and the config tree you would mirror in config/ and a SettingsRepository.
Manager-as-service (Symfony). The core pattern is a settings manager resolved from the container and injected into consumers. Reads/writes go through that service rather than touching the entity manager directly, so caching and type coercion happen in one place.
Namespace + key addressing. Settings are typically grouped by namespace (site, theme, or feature area) and addressed by key within that namespace. When you port this to Laravel, preserve that shape:
Schema::create('settings', function (Blueprint $t) {
$t->string('namespace')->default('core');
$t->string('key');
$t->text('value')->nullable();
$t->string('type')->default('string');
$t->timestamps();
$t->unique(['namespace', 'key']);
});
Read-through cache. The day-to-day win of a settings bundle is not the storage — it is that settings lookups are cheap. Wrap the repository in a Cache::rememberForever("settings:{$namespace}") layer and bust it on write. Without this, every page render hits the settings table several times.
Seeding defaults. Ship defaults in code/config and reconcile them into the DB on boot or via a command. This gives you sane behaviour on a fresh install and a migration path when a new key is introduced. In Laravel this is a SettingsSeeder plus a settings:sync artisan command.
Typed values. Values stored as text need coercion on read (bool, int, json). Centralise casting in the accessor so consumers never call (bool) on a string that might be '0'.
Integration tips for Laravel translation:
.env / config/*.php. Put only editor-tunable values in the DB.Settings facade or a bound singleton (app(Settings::class)) so consumers mirror the Symfony injection pattern.namespace/key/value schema is portable even if the code isn't.swp/settings-bundle are not the source of truth — go upstream.--ignore-platform-reqs gymnastics on PHP 8.1+ and test Doctrine compatibility carefully.namespace/key you expect; if it is present, suspect cache; if absent, suspect a write path that swallowed an exception or a transaction that rolled back.How can I help you explore Laravel packages today?