Laravel 6 Get Config Variable Example – PHP

Today, We want to share with you Laravel 6 Get Config Variable Example.In this post we will show you laravel custom env variables, hear for laravel set env variable in controller we will give you demo and example for implement.In this post, we will learn about laravel get env variable in controller with an example.

Laravel 6 Get Config Variable Example

There are the Following The simple About Laravel: How to access config/Mail variables Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to access variable from config file in laravel 6, so the class ‘app\http\controllers\config’ not found is used for this example is following below.

how to access variable from config file in laravel 6

under /config/app.php

@foreach (Config::get('app.languages') as $lang => $language)

get and set config

Laravel get and set config variables value example

Get Config Variable Value:

$domain = config('app.domain');

//OR

$domain = Config::get('app.domain');
dd($domain);

Set Config Variable Value:

$domain = config('app.domain','https://domain_name.com/');
dd($domain);
OR

$domain = Config::set('app.domain','https://domain_name.com/');
dd($domain);

using Route

Route::get('/test', function () {
    return "it is".config('app.name');
});

Accessing Laravel .env variables in blade

@if (env('APP_ENV')!='Production')
	Your Code / App Is Enviroment Test
@endif

How to access Config variables in laravel 6?

config('app.domain');
// or 
Config::get('app.domain');
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel get env variable in blade.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment