Reputation: 1425
I want custom environment detection. I know how the existing Laravel environment detection works, but I want a more dynamic way. I want to EXPORT a variable in my Ubuntu env, suggesting it's 'development' or 'production', as opposed to using host names and IP addresses.
Any help would be great, thanks.
Upvotes: 2
Views: 229
Reputation: 2208
What I do in my projects is I create a file "app/bootstrap/environment.php"
environment.php
<?php
//Get the environment
$environment = getenv('ENV');
//Check if the environment has been set
if(is_string($environment) && ($environment != '')){
//Return the environment
return $environment;
}else{
//On default return production environment
return 'production';
}
Then in "app/bootstrap/start.php"
start.php
$env = $app->detectEnvironment(function()
{
//Return the environment we're currently using
return require __DIR__.'/environment.php';
});
Works perfect for me.
Upvotes: 2