Correct way to use config files

Posted 2 years ago by ricardovigatti

I was wondering what should be the correct way to use configuration files at my application.

Should I access them directly from the config helper:

config('custom.value');

Or, should I use a Service Provider to handle this:

class CustomServiceProvider extends ServiceProvider
{
    public function register()
    {
         $this->app->singleton('custom', function($value) {
             return config('custom.'.$value);
        });
    }
}

How do you are using custom config files?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.