Last active
August 29, 2015 13:56
-
-
Save stevenwoodson/8935510 to your computer and use it in GitHub Desktop.
Laravel 4 Detect environment set to use the servers SERVER_NAME, default to local for artisan commands
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
$env = $app->detectEnvironment(function(){ | |
// For artisan commands, default to localhost | |
$serverName = 'localhost'; | |
if ( isset($_SERVER["SERVER_NAME"]) && strlen($_SERVER["SERVER_NAME"]) > 0 ){ | |
$serverName = $_SERVER["SERVER_NAME"]; | |
} | |
// List of environments with the server name as the key | |
$serverNames = array( | |
'staging.net' => 'staging', | |
'productionserver.com' => 'production' | |
); | |
if ( isset($serverNames[ $serverName ]) ){ | |
return $serverNames[ $serverName ]; | |
} else { | |
return 'production'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment