Last active
December 29, 2015 14:49
-
-
Save Sprocket/7686650 to your computer and use it in GitHub Desktop.
Laravel helper functions to test for local or production environments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* test for local environment | |
* @param string $env name of environment to test | |
* @return boolean | |
*/ | |
function isLocal($env = 'local') | |
{ | |
return app()->environment() == $env; | |
} | |
/** | |
* test for production environment | |
* @param string $env environment name to test | |
* @return boolean | |
*/ | |
function isProduction($env = 'production') | |
{ | |
return app()->environment() == $env; | |
} | |
/** | |
* test if the app is in dev mode | |
* @return boolean | |
*/ | |
function isDev() | |
{ | |
$env = app()->environment(); | |
$local_names = ['local','dev','development']; | |
$remote_names = ['production','remote']; | |
// assume production fallback | |
return ( in_array($env, $local_names) OR ! in_array($env, $remote_names) ) ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment