How to Access Config Value in Laravel?

Laravel 6 , Laravel

Nicesnippets

30-12-2019


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.....


Recommended Posts