Laravel Custom Env. Variables
Hi guys,
Today i am explained to the how to use in Laravel Custom Env. Variables in laravel 8 and other version in laravel. this example will help you laravel environment variables. i explained simply about how to add custom env variables in laravel.
i would like to share with you add new custom env variables laravel.
I will simple give you example of how to use Laravel Custom Env. Variables in laravel 6, laravel 7 and laravel 8 Project.The Laravel Custom Env.i will give you two examples of how to adding new env variable and how to use it with laravel 6, laravel 7 and laravel 8 application.
Here i will give you two example for laravel custom env. variables example:
Example 1: using env() helper
.env
API_TOKEN=test-demo
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function customeEnv()
{
$customeEnv = env('API_TOKEN');
}
Example 2: using config() helper
config/google.php
<?php
return [
'api_token' => env('GOOGLE_API_TOKEN', 'your-some-default-value'),
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function helper()
{
$aPIToken = config('google.api_token');
}
now you can check your own.
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial