idmarinas/settings-bundle
A Laravel/PHP settings bundle offering a simple, cache-backed key-value store for application configuration. Persist settings in the database, retrieve them through a clean API, and manage grouped or typed values with ease across environments.
Install with Composer:
composer require idmarinas/settings-bundle
Enable the bundle (this is a Symfony bundle, not a Laravel package — see Gotchas) by adding Idmarinas\SettingsBundle\SettingsBundle to config/bundles.php, then import the bundle's routing only if you intend to use its controller/UI.
Look first at:
config/packages/idmarinas_settings.yaml — the bundle's configuration tree (table name, cache, entity class overrides).SettingsInterface service — this is the entry point for reading and writing values.php bin/console doctrine:migrations:migrate after install to create the settings table.First use case: replace hardcoded application settings (site name, contact email, feature flags, maintenance mode) with rows in the settings table, and read them through the injected settings service instead of env/config constants so operators can change them at runtime.
use Idmarinas\SettingsBundle\Settings\SettingsInterface;
class HomeController
{
public function __construct(private SettingsInterface $settings) {}
public function index(): Response
{
$title = $this->settings->get('site.name', 'Default');
// ...
}
}
Typed access. Register settings with an explicit type (string, int, bool, float, array/json) rather than storing everything as strings. The bundle applies casts on read, so get('feature.enabled') returns a real bool, which keeps if checks and Twig conditions clean.
Grouped namespaces. Use dot-notation keys (mail.smtp.host, ui.theme) so you can later bulk-read a group and mirror that structure in your admin UI. This also makes it obvious which subsystem owns a value.
Seeding defaults. Create settings at install time (a data migration or a fixture/console command) instead of scattering if ($settings->has(...)) fallbacks across your code. The bundle will then always return a value with the correct type.
Read-through service, not static calls. Inject SettingsInterface into controllers, services, and form types. This keeps settings mockable in tests and avoids the global-state problems that plague config-constant approaches.
Admin editing surface. The bundle ships a controller for a settings administration UI — wire it under a protected firewall (e.g., ^/admin/settings requires ROLE_ADMIN) rather than exposing it with the default access controls. Edit forms should be built from the same type registry so a bool is a checkbox, an int is a number input, and an array is a JSON textarea with validation.
Cache-aware reads. For hot paths, fetch once per request into a local property rather than calling get() repeatedly; the bundle's cache helps, but the service call itself is not free.
Twig integration. Expose settings to templates via a Twig extension or by passing them from the controller — avoid letting templates query the service ad hoc, which couples view code to the bundle's API.
idmarinas/settings-bundle is a Symfony bundle. There is no Laravel service provider, no config/settings.php publish tag, and no facade. If you're on Laravel, you'd either use the underlying entity/model directly via a thin service, or use a Laravel-native package instead; budget time for this translation before committing.composer.json so an upgrade can't silently alter the shipped migration."yes" in a bool field). The bundle casts on read, but casts can be lossy; validate on save from your admin UI to prevent this.idmarinas_settings.yaml. If you need custom behaviour, decorate SettingsInterface rather than subclassing the concrete service, so the bundle's own wiring continues to work.github.com/idmarinas/settings-bundle/compare/1.1.0...1.2.0. Lock to ~1.2 and review release notes before upgrading in production.How can I help you explore Laravel packages today?