Laravel 4.2 and Dotenv to set environment
To start using Dotenv now it is very simple.
One include the library
#composer.js
"require": {
"laravel/framework": "4.2.*",
"vlucas/phpdotenv": "1.0.*@dev"
},
Two update your start.php
#bootstrap/start.php line 27
Dotenv::load(__DIR__ .'/../');
$env = $app->detectEnvironment(
function()
{
return getenv('APP_ENV');
}
);
Make sure to set your .env file
#.env
APP_ENV='local'
That is it you are set to use it for all your environments.
Update
For Heroku I used this instead
$env = $app->detectEnvironment(
function()
{
if(!isset(getenv('APP_ENV')))
{
Dotenv::load(__DIR__ .'/../');
}
return getenv('APP_ENV');
}
);
Setting the initial APP_ENV using heroku config:set APP_ENV=stage
comments powered by Disqus