How To Get env Variable In Controller Or Blade File

WebSolutionStuff | Jul-26-2020 | Categories : Laravel

In this tutorial, I will give you information on how to get the .env variable in the controller or file. Many times we need to require an environment variable in the controller and blade file like if you are creating PayPal integration then you have stored the app id and secret key in the env file or any other details about hosting, web hosting, credit card, and payment details. But if you haven't any idea how to get it in the controller or blade file.

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








Blade file

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


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

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


Recommended Post
Featured Post

Follow us
facebooklogo github instagram twitter