spatie/laravel-settings
Store strongly typed app settings in Laravel using dedicated Settings classes backed by databases, Redis, and more. Inject settings via the container, read and update properties, then save—keeping configuration structured, testable, and easy to manage.
Settings), decoupling configuration from business logic. This improves maintainability and testability.DateTime, Data objects), making it adaptable to diverse use cases.make:setting, make:settings-migration commands) and integrates seamlessly with existing Laravel workflows (e.g., php artisan migrate).repository(), group()).GeneralSettingsRequest) for updates, aligning with Laravel’s validation ecosystem.SETTINGS_CACHE_ENABLED) requires managing cache invalidation for dynamic updates.Settings::forget() or mocking repositories).config)?SETTINGS_CACHE_ENABLED), and how will we invalidate cache on updates?settings.updated event)?redis config.file, database, memcached). No additional caching layer needed.RefreshDatabase, MockRepository). Supports PestPHP and PHPUnit.Assessment Phase:
.env, hardcoded values, third-party packages like laravel-config).Settings classes and groups (e.g., FeatureFlags, ApiConfig, UserPreferences).Pilot Phase:
Settings class (e.g., LoggingSettings) and its migration.Rollout Phase:
.env overrides) in favor of the new system.Optimization Phase:
settings.* events in Sentry or custom metrics).Settings namespace or migration paths.spatie/laravel-data (via DataCast) or spatie/laravel-activitylog (for auditing).config('app.timezone')) with dependency-injected settings.Infrastructure Setup:
composer require spatie/laravel-settings.php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="config,migrations".settings.php (e.g., default_repository, auto_discover_settings).Development Workflow:
Settings directory in app/ (default: app_path('Settings')).php artisan make:setting FeatureFlags --group=features.public bool $new_ui_enabled = false;).php artisan make:settings-migration InitializeFeatureFlags.Testing:
Settings classes (e.g., validate property types).HttpTests).Deployment:
php artisan migrate post-deploy).Monitoring and Maintenance:
settings.updated event).Settings classes) and version-controlled, reducing "works on my machine" issues.How can I help you explore Laravel packages today?