1.) There's no need to use the Config facade to get configuration values; there is now an equivalent helper-method, config().
2.) In Laravel 5, configurations are no longer "namespaced", which is critical to understand when creating a configuration file (and particularly when merging configuration files).
In Laravel 4, the configuration options for a specific package were nested under a namespaced array, like so:
return [
'myextension' => [
'host' => 'localhost',
'port' => 443,
],
];
In Laravel 5, the equivalent is:
return [
'host' => 'localhost',
'port' => 443,
];
3.) Rather than store your custom configuration values in /config/app.php, a cleaner approach is to store them in your own configuration file, e.g., /config/myname-mypackage.php. You would then retrieve all values with something like:
$config = config('myname-mypackage');
To retrieve only an individual value, simply use dot-notation:
$config = config('myname-mypackage.host');
It is possible to nest configuration files within subdirectories (within /config/), too, which can be necessary in order to prevent conflicts ( @sdebacker asked about this -- great question ).
If you create your configuration file at, for example, /config/myname/mypackage.php, you would access the values using dots in place of the directory separators:
$config = config('myname.mypackage');
4.) It's simple to merge configuration files using a service provider's register() method:
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/../config/config.php', 'myname-mypackage'
);
}
(note that we omit the .php extension in the second argument)
5.) If you're building your own packages, you can specify any number of configuration files to be published when the new vendor:publish artisan command is executed:
public function boot()
{
$this->publishes([
__DIR__.'/../config/config.php' => config_path('myname-mypackage.php'),
]);
}
For more information, refer to the relevant doc at http://laravel.com/docs/master/packages#configuration .