Using Dot Env files to manage settings

Posted: 2014-05-18 10:59:08

Wow. Included in Laravel http://laravel.com/docs/configuration#protecting-sensitive-configuration

  1. removed due to old news

  2. http://mattstauffer.co/blog/laravel-forge-using-environment-variables-for-environment-detection/

Update

I really like the second link and how it sets up a .env file first to just return a simple string. After that you can have the .env.production.php or .env.local.php that laravel can look for.

//bootstrap/start.php
$env = $app->detectEnvironment(function()
{
    if (file_exists(__DIR__ . '/../.env')) {
        return include(__DIR__ . '/../.env');
    } else {
        return 'production';
    }
});

Quite simple at that point to separate all of the environments.