I just updated to the newest Laravel 5,
but it's complaining that it doesn't have a .env file ,
I created the file .env.glenn in my root (where .env.example is)
and set my hostname to glenn
Could someone tell me what I did wrong here?
Exact error:
InvalidArgumentException: Dotenv: Environment file .env not found. Create file with your environment settings at /home/vagrant/Code/testing-stuff/bootstrap/../.env in /home/vagrant/Code/testing-stuff/vendor/vlucas/phpdotenv/src/Dotenv.php on line 20
Checking this right now and apparently .env file is not being loaded until I say it to be loaded by putting Dotenv::load(base_path()); in bootstrap/start.php
Is this desired behaviour? How do you load .env files?
@Andreyco88, yeah L5 changes frequently. I update a minimum once a day on L5 , using git fetch/merge rather than manually doing it so that nothing gets missed and I'm always in sync with the latest commits.
I'm also not using L5 for anything but playing with it, so breaking commits don't bother me.
To make use of separated .env files (.env, .env.testing and so on), just modify bootstrap/environment.php like so:
/*
|--------------------------------------------------------------------------
| Load Environment Variables
|--------------------------------------------------------------------------
|
| Next we will load the environment variables for the application which
| are stored in the ".env" file. These variables will be loaded into
| the $_ENV and "putenv" facilities of PHP so they stay available.
|
*/
if (file_exists(__DIR__.'/../.env.' . $env))
{
Dotenv::load(__DIR__.'/../', '.env.' . $env);
}
else if (file_exists(__DIR__.'/../.env'))
{
Dotenv::load(__DIR__.'/../');
}
Make sure the code block comes after the environment detection stuff in environment.php (see example environment.php).
But: unfortunately you are not able to set the environment in the .env-files because they get loaded after environment detection happens.