bwrigley's avatar

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 run php artisan test
  • .env.dusk.local - for my dusk tests when I run php dusk

which works like this:

  • Vite on windows always loads up .env.testing
  • php artisan test correctly uses .env.testing
  • php artisan dusk swaps out .env for .env.testing and completely ignores .env.dusk.local
  • php artisan tinker correctly uses .env

If I then remove the .env.testing file:

  • Vite on windows loads up .env as I want it to
  • php artisan test uses .env
  • php artisan dusk correctly swaps .env for .env.dusk.local
  • php artisan tinker correctly 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 :)

0 likes
0 replies

Please or to participate in this conversation.