You can merge your package default config with the one published by the user
https://laravel.com/docs/5.5/packages#configuration
In your package service provider:
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/config.php', 'awesome_package'
);
}
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/config.php' => config_path('awesome_package.php'),
]);
}
Then in your package you can simply call config('awesome_package.my_option')
and it will take the user's published value if present, otherwise it will take your package config default value.
This way you don't force any publishing but you provide a way to override values if needed
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community