Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bashy's avatar
Level 65

APP_KEY being pulled from .env.testing when running PHPUnit?

I'm running a fresh install of 5.3 and I have an .env.testing file that I copy to .env for my CI. I also have a build file locally so I can run the same tests.

When I run the local build file, it uses .env.testing and complains about the APP_KEY length. In .env.testing, I have it set as 'key' so I can just run php artisan key:generate on CI.

If I rename .env.testing to something else, it works fine (and I guess it uses the .env version).

Does Laravel 5.3 now use .env.testing? I see no documentation on it.

1) ExampleTest::testBasicExample
RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
0 likes
3 replies
bashy's avatar
Level 65

Using .env.testing.example for now. Always previously used phpunit.xml but optioned not to this time.

slashequip's avatar

Docs here: https://laravel.com/docs/5.3/testing#environment

" Laravel will automatically set the configuration environment to testing. "

Can you not just stick a valid key in your testing .env? And yeah I believe it will just use your production .env file if no specific testing one is present.

bashy's avatar
Level 65

@wearewoolf Yeah I read that but that just means it sets the APP_ENV to testing. That's not the same as using a different environment file. I believe PHPUnit is reading the .env.testing file. It's a change since 5.2 as I've just tested it.

Please or to participate in this conversation.