laravel get env variable in view, blade or controller file. Laravel – How to get .env variable in blade or controller?
laravel get env variable
We can get config variable using env() helper in Laravel. PHP Laravel Get Environment Variables Example Tutorial
Laravel Syntax:
env('VARIABLE_NAME');
Example:
env('APP_URL');
You can see bellow simple laravel 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:
Get environment value in controller
if (env('APP_ENV') == 'local'){ echo 'Local Enviroment'; }
get ENV variable value in Laravel Controller
So, it is very simple to get variable data from .env file like this.