JohnRivs's avatar

How do I specify a sqlite database within .env or phpunit.xml?

I wanna be able to use a different database, but I don't know how to mimic the storage_path() function within those files.

Also, I'd like to avoid editing the database.php file, where it says env('DB_DATABASE', storage_path('database.sqlite')).

0 likes
4 replies
JeffreyWay's avatar

Why do you want to avoid editing your database.php config file? Just modify it to look for an environment var.

'database' => storage_path(env('DB_NAME', 'database.sqlite'))

Then, in your phpunit.xml file (if you wish):

<env name="DB_NAME" value="testing.sqlite" />
davorminchorov's avatar

I remember watching a video here on the site where Jeffrey specified a different DB for testing in his env.testing file which gets picked up when the tests are run. It should be similar for Laravel 5

JeffreyWay's avatar

It's not similar for L5, as the framework, by default, won't look for a env.testing file. You'd have to wire that up yourself.

1 like
JohnRivs's avatar

@JeffreyWay It's because I'm using Lumen, and I don't really want to edit what's inside the vendor folder =/

Please or to participate in this conversation.