0

I have just cloned a laravel project I was working on, into a new machine. I have re-installed all the dependencies, including sqlite and re-configured the database details in the .env file. However, when I try to run php artisan migrate, I get the following error:

 Illuminate\Database\QueryException 

  could not find driver (SQL: PRAGMA foreign_keys = ON;)

  at C:\xampp\htdocs\Soko\vendor\laravel\framework\src\Illuminate\Database\Connection.php:759
    755▕         // If an exception occurs when attempting to run a query, we'll format the error
    756▕         // message to include the bindings with SQL, which will make this exception a
    757▕         // lot more helpful to the developer instead of just the database's errors.
    758▕         catch (Exception $e) {
  ➜ 759▕             throw new QueryException(
    760▕                 $query, $this->prepareBindings($bindings), $e
    761▕             );
    762▕         }
    763▕     }

  1   C:\xampp\htdocs\Soko\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\xampp\htdocs\Soko\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct()

What could be the problem?

Here is my .env file

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite

BROADCAST_DRIVER=log

I had already come across a similar question. And I have tried going to my php.ini file, there are two apparently, one for development and the other for production. I have edited them both, by removing the semicolon in (;extension=pdo_sqlite.dll) and (;extension=sqlite3). I have also tried to tab them out, but as per the comments, nothing has worked.

4
  • stackoverflow.com/questions/64381185/… Commented Aug 28, 2022 at 1:33
  • 1
    Does this answer your question? laravel and phpunit: could not find driver (SQL: PRAGMA foreign_keys = ON;) Commented Aug 28, 2022 at 1:42
  • I had already come across that solution. And I have tried going to my php.ini file, there are two apparently, one for development and the other for production. I have edited them both, by removing the semicolon in (;extension=pdo_sqlite.dll) and (;extension=sqlite3). I have also tried to tab them out, as per the comments, nothing has worked. Commented Aug 28, 2022 at 17:55
  • So there are actually three php.ini files. For windows that is. And that's what's confusing. There is one for development, another for production and now the main one. To be safe you need to change the main one, or all three. Thats what worked for me Commented Aug 28, 2022 at 22:01

1 Answer 1

1
  1. check file .env exist and the same name.
  2. check in .env file database name and configuration exist.
  3. check database exist in SQLite.
  4. check command php artisan return all Laravel commands, if doesn't work execute composer i.
  5. then check the error: could not find driver (SQL: PRAGMA foreign_keys = ON;).
Sign up to request clarification or add additional context in comments.

2 Comments

I have added my .env file. I had already set the database to SQLite. All PHP commands are running fine. As for number 5, how do I check that? I think the issue is that it's still pointing to the SQL server instead of the SQLite one, I don't know why
really I'm not using SQLite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.