Laravel framework 5.0 article

Home >> Laravel framework 5.0 >>

  Access environment value in laravel

This article will explain you, how to access environment value in laravel 5 framework.

<?php

// Simply you can use this code inside your controller function to get environment value.
echo app()->environment();

?>

You can also specifically check for if the current environment is set to local

<?php

echo app()->isLocal(); //If you have set local environment, then output will be 1

if(app()->isLocal()){
    // Some peace of code for local environment 
}

?>

Environment value can be accessed using App namespace like below example

<?php

// use App namespace in your controller
use App;

// Simply you can use this code inside your controller function to get environment value.
echo App::environment();
echo App::isLocal();

?>

Write your comment now