Laravel: Accessing Configuration Values

By | February 18, 2018

All of the configuration files for the Laravel framework are stored in the config directory with each configuration option properly documented.

Accessing Configuration Values

You can access your configuration values using the global config(‘‘, ‘‘) helper function from anywhere in your application.

For Example: You can access configurations from config/app.php configuration file like below:

NOTE: After making any change in configuration file, you must clear the environment configuration cache using below artisan command:

Now, your application will use the updated environment configurations.

Configuration Caching

You can cache all of your configuration files into a single file using the config:cache Artisan command.

Now you should be sure that you are only calling the env() function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env() helper function will return null.

Thanks :)

Leave a Reply

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