dipasquo's avatar

sqlite in-memory db gets "could not find driver" error

New Laravel 5.4 install; tried configuring phpunit to use in-memory sqlite db as such

        <env name="APP_ENV" value="testing"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>

running vendor/bin/phpunit fails with:

1) Tests\Feature\ThreadsTest::a_user_can_browse_threads
Illuminate\Database\QueryException: could not find driver (SQL: select * from sqlite_master where type = 'table' and name = migrations)

If I try another value for DB_DATABASE, other than ':memory:' it fails with a database not found error, but not the 'could not find driver' error -

I have already installed sqlite3 and php5-sqlite packages. Unable to find another solution, help appreciated.

0 likes
3 replies
zachleigh's avatar

You need to install the php sqlite extension.

1 like
dipasquo's avatar

What is this extension, is this different from the php5-sqlite package? I have already installed php5-sqlite. Is there there any associated configuration required that I might be missing? My googling has only come up with dead ends I'm afraid.

dipasquo's avatar
dipasquo
OP
Best Answer
Level 2

Ah ha! I had the wrong sqlite driver installed for php 5.6. With this setup, phpunit works as expected (i.e. test fails, but not because of missing sqlite driver)

PHP 5.6.30-1+deb.sury.org~trusty+1 (cli)

libsqlite3-0/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.1 amd64 [installed]
libsqlite3-dev/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.1 amd64 [installed]
php5.6-sqlite3/trusty,now 5.6.30-10+deb.sury.org~trusty+2 amd64 [installed]
sqlite3/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.1 amd64 [installed]
sqlite3-doc/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.1 all [installed]

Please or to participate in this conversation.