In this artical, i will show you how to get config variable (env variable) in view file laravel. we can get env variable value in controller and blade file too. we can simple print env file variable by using env() helper.

In tthe following example, we will add a new envirnment variable. i create “GOOGLE_URL” variable in .env file and i will access to this variable in blade or controller by using env() helper function.

Syntax :

 

add this line in .env file

 

to access the value of a variable in Blade file

 

use variable in if statement 

 

to access the value of a variable in Controller file

 

use variable in if statement 

 

If your config is cached, you’d have to regenerate it if you change something. Try 

 

Read Also  Laravel Localized Routes 🌍

No Comments

Leave a Reply

your email address will not be published. required fields are marked *

*
*