Configuration
Lumberjack comes with a selection of config files out-of-the-box. These live in the config/
directory and are simple .php
files that return an array
.
Accessing Configuration Values
Let's take a look at config/app.php
:
Here we are proxying an environment variable defined in the .env
file that Bedrock provides. We'd recommend following this pattern, where you should only see getenv
called in your config files.
You can easily access the environment variable using the Rareloop\Lumberjack\Facades\Config
facade.
You can provide a default value too, incase the configuration option does not exist.
If you need to update a config option, you can use the set
method, like so:
You can check whether an item exists in the config:
Note that the has
method only checks whether the config item exists, regardless of its value.
If you set app.mySetting
to an empty value such as false
or null
, has('app.mySetting')
will return true
.
Adding your own config files
Chances are, you're going to need to add your own config files at some point. All you need to do is create a new .php
file in the config/
directory, and have it return an array.
This works because Lumberjack will look for all files in the config/
directory that have a .php
extension and automatically registers all the data to the application's config.
Last updated