How To Get env Variable In Controller Or Blade File

WebSolutionStuff | Jul-26-2020 | Categories : Laravel

In this tutorial i will give you information How To Get env Variable In Controller Or File many time we need to required of env variable in controller and blade file like if you are creating paypal integration then you have stored app id and secret key in env file.But if you haven't any idea how to get it in controller or blade file.

So, let's check how to get those variable data from .env file.

 

Syntax : 

env('VARIABLE_NAME');

 

Example :  

env('PAYPAL_CLIENT_ID');

 

Blade file

@if(env('APP_ENV') == 'local')
   Match
@endif

Controller

if(env('APP_ENV') == 'local')
{ 
  echo 'Match';
}

So, it is very simple to get variable data from .env file like this.

 

Featured Post




Follow us
facebooklogo github instagram twitter