Logo Beartropy Settings

Beartropy Settings

Usage Limitations
Important considerations when using database-driven settings.

Configuration Files

You cannot use the get_setting() helper inside files in the /config directory (e.g., config/services.php). Laravel loads configuration files before the database connection is established. Attempting to use database-driven settings here will result in an error.

Correct Approach

Use config() for static values, or set configuration values dynamically in a Service Provider's boot method:

1// app/Providers/AppServiceProvider.php
2 
3public function boot()
4{
5 // Override config values with database settings safely
6 if (Schema::hasTable('beartropy_settings')) {
7 config(['app.name' => get_setting('general.site.name', config('app.name'))]);
8 }
9}

Service Providers

  • register() method: Avoid using setting() here, as the database connection might not be fully initialized or other services might not be ready.
  • boot() method: This is the recommended place to use setting() if you need to configure services dynamically based on database settings.
Beartropy Logo

© 2026 Beartropy. All rights reserved.

Provided as-is, without warranty. Use at your own risk.