Laravel Custom Config File Example

Jun 16, 2021 . Admin

Hi Guys,

Today In this article i will share you how to create custom config file in your laravel project.

So,in this tutorial i will give you a simple example how to create custom config file in laravel application.

I would like to share with you integrate laravel custom config file.You can easily engender custom configuration file with any laravel application you can use laravel 6, laravel 7, laravel 8.

So, let's started i will explain a bellow full example so follow my steps.

Step 1 : Using env() helper
Path : .env
API_TOKEN = custome_file
Step 2 : Using Config() helper Path : 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

I Hope It Will Help You..

#Laravel 8 #Laravel