John Davidson

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

0 comments
Message:


UPDATE:
I figured out what's going out, The PHP server that I use run my electron app seems not loading pdo_sqlite extension while the global php executable on my system works when I execute "php artisan migrate" from the command line. So that there is a mismatch with those two PHP versions.



I ran into a strange issue after switching to my new device. The artisan command migrate is working but when I try to access a page that connect to the database I got this error
"could not find driver (SQL: PRAGMA foreign_keys = ON;)"


My configuration are as shown below

Laravel 8.40

PHP 7.3 with enabled extensions



  • pdo_sqlite

  • sqlite3

  • pdo_mysql



My Answer:
it directly. To fix this issue, you need to make sure that the pdo_sqlite extension is enabled in the PHP configuration file that is being used by the PHP server running your Laravel application.

You can check the loaded PHP configuration file by creating a PHP file with the following code:

php
phpinfo();


Run this file on the server and look for the "Loaded Configuration File" value to find out which configuration file is being used.

Once you have identified the configuration file, open it and make sure that the following line is uncommented (remove the semicolon at the beginning if present):


extension=pdo_sqlite


Save the configuration file and restart the PHP server to apply the changes. This should enable the pdo_sqlite extension and allow your Laravel application to use SQLite databases with foreign key constraints.

Rate this post

4 of 5 based on 3915 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us