Laravel Add Custom Configuration File Example

By Hardik Savani | April 10, 2021 | Category : Laravel

Now, let's see article of laravel add custom configuration file. This article will give you simple example of laravel custom config file. we will help you to give example of laravel custom configuration file. you can see how to create custom config file in laravel. Let's get started with create your own config file laravel.

you can easily create custom configuration file in laravel 6, laravel 7 and laravel 8 version.

in this example, we will create google.php config file and set api key on there. then we will simply get value using config() helper. let's see example.


now first add your new variable on env file as like bellow:






return [

'api_token' => env('GOOGLE_API_TOKEN', 'your-some-default-value'),


Use it:

Route::get('helper', function(){

$googleAPIToken = config('google.api_token');





now you can check your own.

i hope it can help you...

Tags : Laravel

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: