How to Access Config Value in Laravel?

10-Mar-2023

.

Admin

Hi Guys,

In this Example,I will learn you how to get value from confige file in laravel.you can simply get config value in laravel.

you will use confige() method in controller then get confige file value in your controller.

Example 1 :


/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$config = config('database.default');

dd($config);

}

output :

"mysql" //database name

Example 2 :

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$config =Config::get('app.name');

dd($config);

}

output :

'Laravel'

It will help you.....

#Laravel

#Laravel 6