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

Settings Bundle Laravel Package

customscripts/settings-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle via Composer (if still maintained):

    composer require customscripts/settings-bundle
    

    Register the bundle in config/app.php under providers:

    CustomScripts\SettingsBundle\SettingsBundle::class,
    
  2. Publish Configuration Run:

    php artisan vendor:publish --provider="CustomScripts\SettingsBundle\SettingsBundle" --tag="config"
    

    This generates a config file at config/settings.php.

  3. Define a Setting In config/settings.php, add a new setting under the settings key:

    'settings' => [
        'app' => [
            'name' => 'My App',
            'debug_mode' => false,
        ],
    ],
    
  4. Access a Setting Retrieve values via the Settings facade:

    use CustomScripts\SettingsBundle\Facades\Settings;
    
    $appName = Settings::get('app.name'); // Returns 'My App'
    

Implementation Patterns

Workflow: Dynamic Configuration

  • Environment-Specific Overrides Use settings.php to define environment-specific values (e.g., debug_mode for local vs. production). Example:

    'settings' => [
        'app' => [
            'debug_mode' => env('APP_DEBUG', false),
        ],
    ],
    
  • Caching Settings Enable caching in config/settings.php:

    'cache' => [
        'enabled' => true,
        'ttl' => 60, // Cache for 60 minutes
    ],
    

    Clear cache manually:

    php artisan settings:clear-cache
    

Integration with Laravel Features

  • Service Provider Binding Bind settings to a service provider for dependency injection:

    public function register()
    {
        $this->app->singleton('settings', function () {
            return Settings::get('app');
        });
    }
    
  • Validation Rules Use settings in Form Requests:

    public function rules()
    {
        return [
            'max_upload_size' => 'required|numeric|max:'.Settings::get('app.max_upload_size'),
        ];
    }
    
  • Event Listeners Trigger actions based on settings:

    public function handle()
    {
        if (Settings::get('app.debug_mode')) {
            Log::debug('Debug mode enabled');
        }
    }
    

Gotchas and Tips

Pitfalls

  • No Active Maintenance The bundle is archived and not recommended for production. Consider alternatives like:

  • Limited Documentation The README is minimal. Expect undocumented behaviors (e.g., caching logic, fallback values).

  • No Database Backend Settings are file-based only (config/settings.php). For dynamic updates, you’ll need to:

    1. Restart the Laravel queue/worker.
    2. Clear config cache:
      php artisan config:clear
      

Debugging Tips

  • Check Cache If settings aren’t updating, verify cache:

    php artisan settings:clear-cache
    php artisan config:clear
    
  • Fallback Values The bundle may not handle missing keys gracefully. Use null coalescing:

    $value = Settings::get('app.nonexistent', 'default');
    

Extension Points

  • Custom Storage Override the storage handler by binding a new settings.storage service in a provider:

    $this->app->bind('settings.storage', function () {
        return new CustomSettingsStorage();
    });
    
  • Validation Layer Add validation logic by extending the bundle’s SettingsManager:

    use CustomScripts\SettingsBundle\SettingsManager;
    
    class ExtendedSettingsManager extends SettingsManager
    {
        public function get($key, $default = null)
        {
            $value = parent::get($key, $default);
            // Add custom validation here
            return $value;
        }
    }
    

    Then rebind the service:

    $this->app->singleton('settings.manager', function () {
        return new ExtendedSettingsManager();
    });
    

Configuration Quirks

  • Array vs. Dot Notation The bundle supports both:

    Settings::get(['app', 'name']); // Works
    Settings::get('app.name');     // Also works
    
  • Boolean Values Ensure boolean settings are explicitly typed in config/settings.php:

    'debug_mode' => true, // Not 'debug_mode' => 'true'
    
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai