Laravel 5.2 – Using Custom Config Variables

Quick tip: If you need to store a custom configuration value, that you can call from any Controller, then just do it like this:

1. Add the variable 'key' => 'value'  pair to /config/app.php like so:

The value could also be an array:

2. Then to retrieve the stored value, we can use the config  command, using the examples above, I would do:

If you want to have a default value to use, in case your key didn’t return anything, then just add it as a second argument to the config  command, like so:


This entry was posted in Dev, Laravel, PHP. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *