【问题标题】:Laravel - xampp could not find driver (SQL: select * from sqlite_master where type = 'table' and name = migrations)Laravel - xampp 找不到驱动程序(SQL:select * from sqlite_master where type = 'table' and name = migrations)
【发布时间】:2021-05-24 06:15:01
【问题描述】:

我正在使用 Laravel 8 和 **Xampp (v3.2.4) - ** 并配置 phpunit.xml 以在 sqlite_testing(内存)上运行测试。

<server name="DB_CONNECTION" value="sqlite_testing"/>
<server name="DB_DATABASE" value=":memory:"/>

database.php
'sqlite_testing' => [
  'driver' => 'sqlite',
  'database' => ':memory:'
],

当我运行 ./vendor/bin/phpunit --color --testdox 时出现此错误:

  • Illuminate\Database\QueryException:找不到驱动程序(SQL:select * from sqlite_master where type = 'table' and name = migrations)

为了解决这个问题,我试过了:

  • 在 php.ini 上取消注释 extension=pdo_sqliteextension=sqlite3 并填写 sqlite3.extension_dir = "C:\xampp\php\ext"
  • 已将 c:\xampp\php\ext\libsqlite3.dll 复制到 C:\xampp\apache\bin
  • php artisan config:clear(更新database.php后)
  • 作曲家更新
  • 作曲家需要学说/dbal
  • 检查了 PDO 的 php -m

没有任何效果。仍然收到错误消息:

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

【问题讨论】:

  • 我觉得还是写在config/app.php而不是ENV文件里,测试一下。然后写下启用 extension=pdo_sqlite, extension=sqlite3 后得到的错误?
  • @SamRaskul 感谢您的回答,问题是除了 xampp 我在我的机器上安装了另一个 php 版本。因此,当在该 php.ini 文件上启用 sqlite 时,它​​可以正常工作。

标签: php laravel xampp


【解决方案1】:

按照这些步骤。

1 step: sudo apt install sqlite3
2 step: sudo apt-get install php7.4-sqlite3 -y
3 step: php -m | grep sqlite
4 step: .env

DB_CONNECTION=sqlite
DB_DATABASE={absolute_path}/database.sqlite
#DB_FOREIGN_KEYS=true
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=homestead
#DB_USERNAME=homestead
#DB_PASSWORD=secret

【讨论】:

    猜你喜欢
    • 2021-06-10
    • 1970-01-01
    • 2018-11-05
    • 2020-07-29
    • 2019-09-12
    • 1970-01-01
    • 2016-01-31
    • 2019-03-29
    • 2021-11-14
    相关资源
    最近更新 更多