Laravel, how to get the environment value?

You’re in luck – this was just added in Beta 4 – see here for details

Added App::environment method.

Edit: these are now a number of various ways to get the environment variable as of Laravel 4.1

App::environment()
app()->environment()
app()->env
$GLOBALS['env'] // not recommended - but it is possible

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

App::isLocal()
app()->isLocal()

…or ‘production’

App::isProduction()
app()->isProduction()

You can also specifically check for if the current environment is set to ‘testing’

App::runningUnitTests()
app()->runningUnitTests()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)