Weave 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

Development Settings Laravel Package

mikebronner/development-settings

A Laravel package for managing development-only settings, keeping environment configuration organized and out of production. Useful for toggling debug options, feature flags, and local overrides while building and testing applications.

Deep Wiki
Context7

Getting Started

First Steps

  1. Installation

    composer require mikebronner/development-settings
    

    Publish the config file:

    php artisan vendor:publish --provider="MikeBronner\DevelopmentSettings\DevelopmentSettingsServiceProvider" --tag="config"
    
  2. Basic Configuration Edit config/development-settings.php to define:

    • repositories: Array of GitHub/GitLab/Bitbucket repo URLs.
    • settings: Key-value pairs for your dev environment (e.g., database.connections.local.host).
    • sync_interval: How often to check for updates (in minutes).
  3. First Use Case Define a setting in your config:

    // config/development-settings.php
    'settings' => [
        'app.debug' => true,
        'mail.mailers.local.host' => 'mailhog',
    ],
    

    Run the sync command:

    php artisan development-settings:sync
    

    The package will fetch the latest settings from your configured repositories and apply them to your .env file.


Implementation Patterns

Common Workflows

  1. Repository-Based Sync

    • Store settings in a dedicated branch (e.g., dev-settings) or a specific file (e.g., .dev-settings.yml) in each repo.
    • Example .dev-settings.yml in a repo:
      app.debug: true
      queue.connections.local.driver: sync
      
    • The package parses these files and merges them into your local .env.
  2. Conditional Overrides Use Laravel’s config caching to override settings dynamically:

    // config/app.php
    'debug' => env('APP_DEBUG', config('development-settings.app.debug', false)),
    
  3. Environment-Specific Sync Run sync only in specific environments (e.g., local):

    php artisan development-settings:sync --env=local
    
  4. Scheduled Syncs Add a cron job to auto-sync settings (e.g., every 5 minutes):

    * * * * * cd /path-to-project && php artisan development-settings:sync >> /dev/null 2>&1
    
  5. Custom Sync Logic Extend the SyncSettings class to add logic (e.g., validate settings before applying):

    // app/Providers/DevelopmentSettingsServiceProvider.php
    use MikeBronner\DevelopmentSettings\SyncSettings;
    
    class DevelopmentSettingsServiceProvider extends ServiceProvider
    {
        public function register()
        {
            $this->app->singleton(SyncSettings::class, function ($app) {
                return new class extends SyncSettings {
                    protected function validateSettings(array $settings): array
                    {
                        // Custom validation logic
                        return $settings;
                    }
                };
            });
        }
    }
    

Gotchas and Tips

Pitfalls

  1. .env File Conflicts

    • The package overwrites .env values for keys defined in development-settings.php. Backup your .env before syncing.
    • Fix: Exclude sensitive keys (e.g., APP_KEY) from sync by prefixing them in config:
      'settings' => [
          '!APP_KEY' => env('APP_KEY'), // Skip sync for this key
      ],
      
  2. Git Repository Access Issues

    • The package uses GitHub/GitLab/Bitbucket APIs. Ensure:
      • Personal access tokens are configured in config/development-settings.php under auth.
      • Repos are public or the token has repo scope.
    • Fix: Use SSH keys for private repos (requires customizing the GitRepository class).
  3. Caching Quirks

    • Laravel’s config cache (php artisan config:cache) may not reflect new settings immediately.
    • Fix: Clear the cache after syncing:
      php artisan config:clear
      
  4. Merge Conflicts

    • If .env has manual overrides, they may be lost during sync.
    • Fix: Use ! prefix to exclude keys or manually merge after sync.
  5. Performance with Many Repos

    • Syncing 10+ repos can be slow. Use sync_interval to throttle requests.

Debugging Tips

  • Enable verbose output:
    php artisan development-settings:sync --verbose
    
  • Check raw settings before applying:
    // In a Tinker session:
    $settings = app(\MikeBronner\DevelopmentSettings\SyncSettings::class)->getSettings();
    dd($settings);
    
  • Test locally with a dummy repo first.

Extension Points

  1. Custom Data Sources Extend MikeBronner\DevelopmentSettings\DataSources\DataSourceInterface to pull settings from:

    • A database table.
    • An external API.
    • A shared network drive.
  2. Post-Sync Hooks Add logic after sync via the synced event:

    // In EventServiceProvider
    protected $listen = [
        \MikeBronner\DevelopmentSettings\Events\SettingsSynced::class => [
           \App\Listeners\RestartServices::class,
       ],
    ];
    
  3. UI Integration Build a dashboard to view sync status or manually trigger syncs:

    Route::get('/dev-settings', function () {
        return response()->json(app(\MikeBronner\DevelopmentSettings\SyncSettings::class)->getLastSync());
    });
    
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.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route