realtebo's avatar

Package Test: could not find driver for SQLite - (Laravel 8 - Windows 10)

I am developing a package using latest laravel 8.x. In on a windows 10 machine.

I am trying to create tests. I start tests in this way

C:\php-7.3.18-Win32-VC15-x64\php.exe C:/progetto/packages/product_image/vendor/phpunit/phpunit/phpunit --configuration C:\progetto\packages\product_image\phpunit.xml 

In the .xml I configured

    <php>
        <server name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>
    </php>

Test crashed saying me

Illuminate\Database\QueryException : could not find driver (SQL: PRAGMA foreign_keys = ON;)

C:\progetto\packages\product_image\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
C:\progetto\packages\product_image\vendor\laravel\framework\src\Illuminate\Database\Connection.php:631
C:\progetto\packages\product_image\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
C:\progetto\packages\product_image\vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php:313
C:\progetto\packages\product_image\vendor\laravel\framework\src\Illuminate\Database\SQLiteConnection.php:37

Looking at stack trace I noticed that is using SQLiteConnection. So I think .xml configs are correct.

So I asked my php to dump infos.

C:\php-7.3.18-Win32-VC15-x64\php.exe -i

Here I can see sqlite3 extension loaded.

sqlite3

SQLite3 support => enabled
SQLite Library => 3.28.0

Directive => Local Value => Master Value
sqlite3.defensive => 1 => 1
sqlite3.extension_dir => no value => no value

What am I doing wrong?

0 likes
1 reply
realtebo's avatar

Solved !

I installed extension sqlite but forgot to install not the extension pdo-sqlite.

After installing both all works.

Please or to participate in this conversation.