Ad

PDOException: Could Not Find Driver But SQLite3 Enabled

- 1 answer

I'm trying to run PHPUnit test in an Nginx-Alpine docker image which uses SQLite as the database for testing

I have sqlite3 extension installed, and this is the output from php -r "phpinfo();"

enter image description here

However, when I run the test is still get this error

Tests\Feature\CardTypeTest::testCardTypeCreation
Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA writable_schema = 1;)

/var/www/vendor/illuminate/database/Connection.php:664
/var/www/vendor/illuminate/database/Connection.php:624
/var/www/vendor/illuminate/database/Connection.php:333
/var/www/vendor/illuminate/database/Schema/SQLiteBuilder.php:18
/var/www/vendor/illuminate/database/Console/Migrations/FreshCommand.php:79
/var/www/vendor/illuminate/database/Console/Migrations/FreshCommand.php:46
/var/www/vendor/illuminate/container/BoundMethod.php:32
/var/www/vendor/illuminate/container/BoundMethod.php:90
/var/www/vendor/illuminate/container/BoundMethod.php:34
/var/www/vendor/illuminate/container/Container.php:576
/var/www/vendor/illuminate/console/Command.php:183
/var/www/vendor/symfony/console/Command/Command.php:255
/var/www/vendor/illuminate/console/Command.php:170
/var/www/vendor/symfony/console/Application.php:934
/var/www/vendor/symfony/console/Application.php:273
/var/www/vendor/symfony/console/Application.php:149
/var/www/vendor/illuminate/console/Application.php:90
/var/www/vendor/illuminate/console/Application.php:182
/var/www/vendor/laravel/lumen-framework/src/Console/Kernel.php:165
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:315
/var/www/vendor/laravel/lumen-framework/src/Testing/DatabaseMigrations.php:14
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:89
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:76
/var/www/tests/Feature/CardTypeTest.php:21

Caused by
PDOException: could not find driver

/var/www/vendor/illuminate/database/Connectors/Connector.php:70
/var/www/vendor/illuminate/database/Connectors/Connector.php:46
/var/www/vendor/illuminate/database/Connectors/SQLiteConnector.php:25
/var/www/vendor/illuminate/database/Connectors/ConnectionFactory.php:218
/var/www/vendor/illuminate/database/Connection.php:919
/var/www/vendor/illuminate/database/Connection.php:944
/var/www/vendor/illuminate/database/Connection.php:399
/var/www/vendor/illuminate/database/Connection.php:325
/var/www/vendor/illuminate/database/Connection.php:657
/var/www/vendor/illuminate/database/Connection.php:624
/var/www/vendor/illuminate/database/Connection.php:333
/var/www/vendor/illuminate/database/Schema/SQLiteBuilder.php:18
/var/www/vendor/illuminate/database/Console/Migrations/FreshCommand.php:79
/var/www/vendor/illuminate/database/Console/Migrations/FreshCommand.php:46
/var/www/vendor/illuminate/container/BoundMethod.php:32
/var/www/vendor/illuminate/container/BoundMethod.php:90
/var/www/vendor/illuminate/container/BoundMethod.php:34
/var/www/vendor/illuminate/container/Container.php:576
/var/www/vendor/illuminate/console/Command.php:183
/var/www/vendor/symfony/console/Command/Command.php:255
/var/www/vendor/illuminate/console/Command.php:170
/var/www/vendor/symfony/console/Application.php:934
/var/www/vendor/symfony/console/Application.php:273
/var/www/vendor/symfony/console/Application.php:149
/var/www/vendor/illuminate/console/Application.php:90
/var/www/vendor/illuminate/console/Application.php:182
/var/www/vendor/laravel/lumen-framework/src/Console/Kernel.php:165
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:315
/var/www/vendor/laravel/lumen-framework/src/Testing/DatabaseMigrations.php:14
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:89
/var/www/vendor/laravel/lumen-framework/src/Testing/TestCase.php:76
/var/www/tests/Feature/CardTypeTest.php:21

Ad

Answer

Finally observed that the php-pdo_sqlite extension was missing.

Installed it using apk add --update php-pdo_sqlite and it's working fine now.

Ad
source: stackoverflow.com
Ad