How to get .env variable in blade or controller in Laravel?

Posted by LaravelIndia - 1 year ago

Syntax:

env('YOUR_VARIABLE_NAME');

Example:

env('APP_URL');

Use in Blade File:

@if (env('APP_ENV') == 'local')
   Local Enviroment
@endif

Use in Controller File:

if (env('APP_ENV') == 'local'){
    echo 'YOUR Local Enviroment';
}