Hi I deploy my application based on laravel 4 to fortrabbit. I try setting local and production environment
in bootstrap/start.php
I modify
$env = $app->detectEnvironment(function () {
return getenv('LARAVEL_ENV') ?: 'local';
});
on fortrabbit i define env_var LARAVEL_ENV to prod
but if i try in fortrabbit
php artisan env
i obtain local instead of prod
what is wrong in my code?
After setting the environment variable in your Fortrabbit's dashboard, you need to write this in your start.php
file:
$env = $app->detectEnvironment(function () {
return isset($_SERVER['LARAVEL_ENV'])
? $_SERVER['LARAVEL_ENV']
: 'prod';
});
Note that it is better to fallback to the production environment in case there is no environment variable, since you don't want to mistakenly show debug logs on your production app.