0

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?

user2094178
  • 9,204
  • 10
  • 41
  • 70
mardon
  • 1,065
  • 1
  • 11
  • 29

1 Answers1

1

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.

lowerends
  • 5,469
  • 2
  • 24
  • 36
  • but this is prod even if I on my localhost, where I havent set LARAVEL_ENV – mardon Sep 24 '14 at 10:18
  • Indeed, so you should explicitly set the `LARAVEL_ENV` value to `local` on your local environment. This is of course not obligated, but it may save you from showing debug logs on your production environment one day. If you don't want this, then you can just replace `'prod'` by `'local'` in the above code. – lowerends Sep 24 '14 at 10:23