Aug 23, 2023
0
Level 5
Problems using correct .env files in Homestead
I'm sure I've missed something obvious here but I don't seem to be able to get my various scenarios to use different .env files.
I'm running Homestead on Windows. My site is served from within Homestead, but Vite server has to run on Windows.
in my Homestead.yaml I have set:
variables:
- key: APP_ENV
value: local
In my project I have 3 .env files:
-
.env- for day to day development -
.env.testing- for my unit/feature testing to be used when I runphp artisan test -
.env.dusk.local- for my dusk tests when I runphp dusk
which works like this:
- Vite on windows always loads up
.env.testing -
php artisan testcorrectly uses.env.testing -
php artisan duskswaps out.envfor.env.testingand completely ignores.env.dusk.local -
php artisan tinkercorrectly uses.env
If I then remove the .env.testing file:
- Vite on windows loads up
.envas I want it to -
php artisan testuses.env -
php artisan duskcorrectly swaps.envfor.env.dusk.local -
php artisan tinkercorrectly uses.env
I've seen many posts saying to run dusk with --env=dusk.local or --env=dusk but neither of these seem to temporarily swap out the .env file.
I've tried creating a phpunit.dusk.xml file but dusk seems to ignore that.
As you can see I've got myself into a complete mess!
Thanks for any help :)
Please or to participate in this conversation.