Just curious. Do you by any chance have $connection set on any models or ::connection() on any migrations?
Oh and is this path absolute? Like from the root of your computer
DB_DATABASE=/path-to-db/database.sqlite
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello! I am unsure where I am doing wrong here and would appreciate any help. I have been all around the internet not finding any reason it should be this hard to get working. I realize I must've missed some obvious detail somewhere but I can't find it.
The problem:
What I have tried:
I have spent hours searching for an explanation and the reason I run the "config" commands is just a result of that search. This is my current setup:
.env
DB_CONNECTION=sqlite
DB_DATABASE=/path-to-db/database.sqlite
DB_TEST_DRIVER=sqlite
DB_TEST_DATABASE=:memory:
config/database.php
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'testing' => [
'driver' => env('DB_TEST_DRIVER'),
'database' => env('DB_TEST_DATABASE'),
'prefix' => '',
],
// ...
],
phpunit.xml
<php>
<server name="APP_ENV" value="testing"/>
//...
<server name="DB_CONNECTION" value="testing" />
</php>
I read a thread on stackoverflow suggesting that you should have multiple .env files and then run the config:cache command to switch between them. But that can't be -the- solution to this, right? Since Laravel writes in the documentation that it's "built with testing in mind" it should be easy to apply TDD without having the need to run separate commands constantly? Or have I misunderstood something terribly?
Many thanks for any input!
As @sinnbeck says, or try to use other environment like Laravel Valet: https://laravel.com/docs/6.x/valet
Please or to participate in this conversation.