In this example, you will learn how to access config variable in laravel. you can understand a concept of get env variable laravel controller. I’m going to show you about get env variable laravel 7/6 blade. We will look at example of laravel get env variable in blade.
When i was new to laravel and i was trying to get my google api key from .env file. i created "GOOGLE_MAP_ID" variable in .env file and i need to access on blade file js code. i used that key by using env() function. We can access config variable using env() helper.
Syntax:
env('VARIABLE_NAME');
Example:
env('APP_URL');
You can see bellow simple example how you can get env file variable in blade or controller file.
Blade File:
@if (env('APP_ENV') == 'local')
Local Enviroment
@endif
Controller File:
if (env('APP_ENV') == 'local'){
echo 'Local Enviroment';
}
You can simple get env file value like this way.
I hope it can help you...
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Laravel 8 Google Recaptcha Tutorial Example
Google Recaptcha is Captcha service by G...How to get One Day Old Records in Laravel using Carbon?
In this article, I will share with you h...How to Convert a String to a Number in PHP
Use Type Casting As we know PHP does...Autocomplete Example with React16
We are going to learn how to build...How to increase and decrease image size using JavaScript
Use the JavaScript width and&n...