How to Access Config Value in Laravel?

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
How to Access Config Value in Laravel

Hello Dev’s, Today now in this Example,I will show you how to get value from config file in laravel application . We can simply get config value in our laravel application.

Here we will use config() method in controller then get config file value in our 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' 

Read also : How To Set Bcc And Cc Mail Address In Laravel Mail?

I hope it will help you. Also you can follow us on Facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →