+1
Specifying a testing database in an .env.testing file
I am trying to set up (migrate) a testing database with Lumen 5.4.5. I was hoping I could do this by making a separate .env.testing file and specifying the database config like
...
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=testmedb
DB_USERNAME=homestead
DB_PASSWORD=secret
...
and then running php artisan migrate --env=testing. This doesn't seem to be working however. I just get a Nothing to migrate. message in the console, so it seems Artisan is not picking my .env.testing but simply my .env. Perhaps this is not possible out of the box with Lumen? It says in the Laravel documentation that it should be possible, but indeed the Lumen doesn't mention this at all. And running php artisan migrate -h does show an
--env[=ENV] The environment the command should run under
option. That's a bit confusing. Come to think of it; I do see in bootstrap/app.php
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
which just seems to load the .env straight away. So I guess that pretty much explains it...
I know I can just add a database.php config file and specify a testing db connection in there like proposed here, but I think having a separate .env.testing is just a bit cleaner.
Despite my assumptions and suspections, did anyone perhaps manage to do this with a separate .env.testing using Lumen?
Please or to participate in this conversation.