Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 - Get Package Config

Normally we can get config via something like this:

$value = Config::get('app.timezone');

If want to get the config in the package, we can do something like this:

$value = Config::get('package::configfile')

How can I link the config file in my package so that I can use it that way?

like image 428
user1995781 Avatar asked Jan 09 '23 21:01

user1995781


1 Answers

Make sure to read the Package Development chapter in the documentation.

In Laravel 5 there are no config "namespaces" anymore. You just load your config like this in the Service Provider:

$this->publishes([
     __DIR__.'/path/to/config/file.php' => config_path('package/file.php'),
]);

And access it like this:

Config::get('package.file');

or:

config('package.file');
like image 126
lukasgeiter Avatar answered Jan 21 '23 13:01

lukasgeiter