How to check Laravel application running Environment?

Created at 06-Dec-2022 , By samar

There are different ways to check the laravel application running environment. We will discuss them one by one.

Sometimes, we have to check the application environment and based on that we have to do some task in our app. So there are some methods available in Laravel to determine the current environment of Laravel application to solve the problem.

You can call the environment method on app facade and get the current working environment $environment = App::environment();.

  • Check the running environment in the controller using Laravel

    In your controller, you can use app facade to get the current working environment in Laravel. You have to import App facade in your controller file and use the environment() method to get the current running environment.


    if (App::environment('local')) {
        // The environment is local
    if (App::environment(['local', 'staging'])) {
        // The environment is either local OR staging...
  • Get the current working environment in Laravel blade


        <p> in Local environment </p>

    You have to place code in your blade file and pass the value to environment method which is exists in .env file (APP_ENV=local) or configuration file (config/app.php) 'env' => env('APP_ENV', 'local'),.

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.