How to Get Config Variable Value in Laravel?
Now, let's see an example of how to get config value in laravel. In this article, we will implement a how to get value from config file in laravel. This example will help you laravel get config value in controller. I’m going to show you about laravel get config value in blade.
You can use this example with laravel 6, laravel 7, laravel 8 and laravel 9 versions.
Whenever you need to get configuration files value then you can get using config helper in Laravel. If you are working on Laravel then you should use Config facade for get and set value of config file. Maybe sometimes we require to get application url from app.php file or database name from database.php file so you can get this way:
class DemoController extends Controller
* Write code on Method
* @return response()
public function index(Request $request)
/* Example 1: Get Config Value in Laravel */
$appName = Config::get('app.name');
/* Example 2: Get Config Value in Laravel */
$appName2 = config('app.name');
I hope it can help you...
We are Recommending you
- Laravel Order By Multiple Columns Example
- How to Create Model in Laravel using Command?
- How to Add Google Map in Laravel?
- How to Install Laravel in Ubuntu Server?
- Laravel Sweet Alert Confirm Delete Example
- Laravel Add Custom Configuration File Example
- How to Add Foreign Key in Laravel Migration?
- Laravel Livewire Delete Confirmation Example
- Laravel Model Events Tutorial
- How to Set Config Value Dynamically in Laravel?
- Laravel Redirect Back to Previous Page After Login Example
- How to Get Query Log in Laravel Eloquent?