Reputation: 2933
I thought this PR fixed the issue I am having - but I have this patch and it's still not working as I expected - what am I missing or mis-understanding?
https://github.com/symfony/symfony/pull/28533
I have created a .env.test with the following:
DATABASE_URL_TEST=mysql://apps:@localhost:3306/mydb_test
Then I dropped a doctrine.yaml inside the config/packages/test
directory.
Symfony v4.2.3
However when I run this command from CLI:
APP_ENV=test bin/console doctrine:database:create --env=test
I am getting an error:
Environment variable not found: "DATABASE_URL_TEST".
Clearly the .env.test
file is not being loaded - how do I get a specific environment configuration file to load - other than .env???
Upvotes: 4
Views: 2858
Reputation: 39129
If indeed your application was a Symfony 3.x application at some point, what I would guess is that, during the upgrade process, those two lines out of the UPGRADE procedure were missed:
Then, upgrade the contents of your console script and your front controller:
Indeed, it seems like bin/console
has been changed recently to reflect the adaptation done on the DotEnv
component: https://github.com/symfony/recipes/commit/3e471cbc7d359b3ab245f3b0748d698e8d29692c#diff-2af50efd729ff8e61dcbd936cf2b114b
Mind that you'll also need https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
Upvotes: 3
Reputation: 4114
I had a very similar problem. My issue was that my phpunit.xml.dist
was pointing to the wrong bootstrap file:
Previously:
bootstrap="vendor/autoload.php"
Changed to:
bootstrap="tests/bootstrap.php"
Upvotes: 3