I want to have a .env.testing file for my tests, specifically for setting a local testing database. But do I have to copy everything from .env into .env.testing, just to change one line? Can’t I do some command that tells php artisan test
that I want to load everything from .env, and then override DB_DATABASE by having only this line in .env.testing?
2
Answers
I ended up just changing this line in my phpunit.xml file:
It even was already there, I just had to uncomment it and change the database name.
if you want to change the env system of Laravel, you can override this method in the App/Http/Kernel.php file
I think it’s a bit tricky and dangerous to change Laravel env system, but you can analyze how it’s working by reading methods in the file vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php