Laravel Custom Config File Tutorial

Laravel 8 , Laravel 7 , Laravel , Laravel 6

Nicesnippets

1490

28-05-2021


Laravel Custom Config File Tutorial

Hi guys,

Today i am explained to the how to use laravel custom config file in your project. This article will give you simple example of laravel custom config file. I will help for you in this exampleof laravel custome configration file. I explained simply about how to use laravel custom config file.

I would like to share with you add laravel custom config file.You can easily create custom configuration file with laravel 6, laravel 7 and laravel 8 application.

Let's get started with create your own config file laravel.

step 1: using env() helper


.env

API_TOKEN = custome_file

step 2: using config() helper

config/google.php

<?php

return [

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

];

step 3:controller

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function helper()

{

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

dd($apiToken);

}

Output:

custome_file

now you can check your own.

i hope it can help you...


Recommended Posts