Last active
December 20, 2019 02:47
-
-
Save mabasic/19c527702862039777d8 to your computer and use it in GitHub Desktop.
Laravel - detectEnvironment
This file contains 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
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Detect The Application Environment | |
|-------------------------------------------------------------------------- | |
| | |
| Laravel takes a dead simple approach to your application environments | |
| so you can just specify a machine name for the host that matches a | |
| given environment, then we will automatically detect it for you. | |
| | |
*/ | |
if(!function_exists('getEnvironment')) | |
{ | |
function getEnvironment() | |
{ | |
$environmentList = [ | |
'local' => ['homestead'], | |
'windows' => ['mabasic-laptop', 'mabasic-box'] | |
]; | |
$appEnv = function () | |
{ | |
return $_ENV['APP_ENV']; | |
}; | |
return isset($_ENV['APP_ENV']) ? $appEnv : $environmentList; | |
} | |
} | |
$env = $app->detectEnvironment(getEnvironment()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@nandwabee xD Did not see your comment until now. I've fixed the code now.
Happy copy/pasting!