Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spatie Laravel Settings Plugin Laravel Package

filament/spatie-laravel-settings-plugin

Filament plugin to manage app settings stored with spatie/laravel-settings. Generate settings pages, build forms with Filament fields that map to your settings class properties, and automatically load/save values from the database with minimal setup.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • Decoupled Configuration: Leverages spatie/laravel-settings for centralized, structured configuration management, aligning with Laravel’s modularity.
    • Filament UI Integration: Provides a dedicated admin panel for settings management, reducing manual database interactions and improving developer experience.
    • Type Safety: Supports PHP 8+ typed settings, enhancing IDE support and runtime validation.
    • Extensibility: Plugin-based architecture allows for customization (e.g., adding validation, default values, or UI tweaks).
    • Separation of Concerns: Isolates settings logic from business logic, adhering to SOLID principles.
  • Fit for Use Cases:

    • Ideal for admin-heavy Laravel applications (e.g., SaaS platforms, CMS, or dashboards) where dynamic configuration is critical.
    • Less critical for static-configuration projects (e.g., internal tools with hardcoded settings).
    • Microservices: Useful for centralized settings across services if shared via a config service (e.g., Redis, database).

Integration Feasibility

  • Prerequisites:

    • Requires Filament v3.x and Laravel 9+ (PHP 8.1+ recommended).
    • spatie/laravel-settings must be installed as a dependency (handled automatically via the plugin).
    • Database migrations for settings tables (included in the package).
  • Key Dependencies:

    • Filament: Tight coupling with Filament’s admin panel; may require UI adjustments if using custom Filament themes.
    • Database: Relies on SQL storage (MySQL, PostgreSQL, SQLite). No support for alternative backends (e.g., Redis, cache).
    • Caching: Settings are cached by default (via Laravel’s cache); requires understanding of cache invalidation.
  • Customization Points:

    • Override default settings via Settings::extend() or custom Filament resources.
    • Extend UI via Filament’s widget system or custom panels.

Technical Risk

  • Medium Risk:

    • Filament Version Lock: Breaking changes in Filament v3.x could require plugin updates. Monitor Filament’s release notes.
    • Database Schema Changes: Future versions of spatie/laravel-settings may alter migrations (e.g., adding columns).
    • Performance: Heavy settings usage (e.g., thousands of settings) may impact query performance. Test with production-like data.
    • Security: Ensure settings are not exposed in logs or error messages (e.g., sensitive API keys). Use Settings::for() guards where needed.
  • Mitigation:

    • Testing: Validate with a staging environment mirroring production load.
    • Fallbacks: Implement graceful degradation (e.g., cache fallbacks for critical settings).
    • Monitoring: Track setting access patterns (e.g., via Laravel’s query log or New Relic).

Key Questions

  1. Use Case Alignment:

    • Are settings frequently updated via UI, or mostly static? (Plugin excels in dynamic scenarios.)
    • Do you need multi-tenancy? (Requires custom logic; plugin supports it but needs setup.)
  2. Filament Compatibility:

    • Are you using custom Filament widgets/resources? (May need UI adjustments.)
    • What’s your Filament version strategy? (Stick to LTS or track latest?)
  3. Data Layer:

    • What’s your database size/read volume for settings? (Benchmark with 10K+ settings.)
    • Do you need audit logs for settings changes? (Not natively supported; consider laravel-audit integration.)
  4. DevOps:

    • How will you handle environment-specific settings? (Use Settings::group() or separate configs.)
    • What’s your deployment strategy for settings changes? (Blue-green? Feature flags?)
  5. Alternatives:

    • Could Laravel’s config cache or environment variables suffice for simpler needs?
    • Is Filament’s built-in settings panel (if available) a better fit?

Integration Approach

Stack Fit

  • Core Stack:

    • Laravel 9+ (PHP 8.1+): Required for spatie/laravel-settings and Filament v3.
    • Filament v3.x: Mandatory for the plugin’s UI integration. Ensure your Filament setup is up-to-date.
    • Database: MySQL/PostgreSQL/SQLite (no alternatives supported). Test with your primary DB.
    • Caching: Laravel’s cache (e.g., Redis, Memcached) for performance. Configure settings_cache_driver in .env.
  • Additional Tools:

    • Laravel Scout/Algolia: If settings include searchable fields (e.g., "feature flags").
    • Laravel Horizon: For async setting updates (e.g., webhooks triggering setting changes).
    • Laravel Telescope: Monitor setting queries and cache hits/misses.
  • Conflicts:

    • Custom Settings Tables: Avoid if you already have a settings table (e.g., from a legacy system).
    • Filament Plugins: Ensure no other Filament plugins override settings routes/resources.

Migration Path

  1. Pre-Integration:

    • Audit existing settings:
      • Identify hardcoded configs (e.g., in config/app.php).
      • List database-stored settings (e.g., configurations table).
    • Plan data migration:
      • Use Settings::set() to backfill existing values.
      • Example:
        Settings::set('app.name', config('app.name'));
        Settings::set('mail.from.address', config('mail.from.address'));
        
  2. Installation:

    • Composer:
      composer require filament/spatie-laravel-settings-plugin
      
    • Publish assets (if customizing UI):
      php artisan vendor:publish --tag="filament-settings-plugin-assets"
      
    • Run migrations:
      php artisan migrate
      
  3. Configuration:

    • Define settings in config/filament-settings.php:
      'settings' => [
          'app' => [
              'name' => 'string',
              'timezone' => 'string',
          ],
          'mail' => [
              'from' => [
                  'address' => 'string',
                  'name' => 'string',
              ],
          ],
      ],
      
    • Register settings in AppServiceProvider:
      use Filament\Settings\SettingsGroup;
      use Spatie\LaravelSettings\Settings;
      
      public function boot(): void
      {
          Settings::group('app', function (SettingsGroup $group) {
              $group->addTextEntry('name');
              $group->addSelectEntry('timezone', [
                  'UTC' => 'UTC',
                  'America/New_York' => 'New York',
              ]);
          });
      }
      
  4. UI Setup:

    • Access settings via Filament’s admin panel (default route: /admin/settings).
    • Customize the panel by extending the SettingsPage class.
  5. Post-Integration:

    • Replace hardcoded configs with Settings::get() calls:
      $appName = Settings::get('app.name');
      
    • Deprecate old config files (e.g., config/app.php) via Laravel’s config caching.

Compatibility

  • Laravel Ecosystem:

    • Packages: Compatible with most Laravel packages (e.g., spatie/laravel-permission for role-based settings access).
    • Service Providers: Register settings in AppServiceProvider or a dedicated SettingsServiceProvider.
    • Testing: Use Settings::fake() in PHPUnit tests.
  • Frontend:

    • Livewire/Inertia: Fetch settings via API routes (e.g., route('filament.settings')).
    • JavaScript: Cache settings in window.__settings__ for performance.
  • Multi-Tenancy:

    • Use Settings::for($tenant) if using stancl/tenancy or similar.
    • Store tenant-specific settings in a separate group (e.g., tenants.{id}.settings).

Sequencing

  1. Phase 1: Core Integration (1–2 weeks):

    • Install package, publish migrations, and define basic settings.
    • Migrate existing configs to the new system.
    • Test UI and API access.
  2. Phase 2: Customization (1 week):

    • Extend UI (e.g., custom widgets, validation).
    • Add multi-tenancy or role-based access if needed.
    • Implement caching strategies.
  3. Phase 3: Rollout (1 week):

    • Deprecate old config files (with warnings).
    • Update frontend to use new settings API.
    • Monitor performance and errors.
  4. Phase 4: Optimization (Ongoing):

    • Optimize queries (e.g., batch fetching settings).
    • Add monitoring for slow setting loads.
    • Document new workflows for developers.

Operational Impact

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime