skip to Main Content

I’m completely new to laravel and learning from a course.
Literally just started creating a project same way in the tutorial, the tutorial goes to the laravel welcome page when artisan serve ran but mine gives me

In my terminal I wrote "composer create-project laravel/laravel myProjectName"

Then wrote "php artisan serve"

I expected to see a welcome page in the browser but instead got an error

could not find driver(connection:sqlite:SQL:PRAGMA foreign-keys=on;)

2

Answers


  1. The error message "could not find driver(connection:sqlite:SQL:PRAGMA foreign-keys=on;)" indicates that Laravel is unable to find the SQLite database driver.

    Here are a few steps you can take to resolve this issue:

    Check SQLite Extension: Ensure that the SQLite extension is enabled in your PHP configuration. If you’re using XAMPP, WAMP, or MAMP, you can typically enable extensions through their respective control panels or by editing the php.ini file.

    Install SQLite Driver: If the SQLite extension is not enabled, you’ll need to install it. The method for installing extensions depends on your operating system and PHP version. For example, on Ubuntu, you can install the SQLite driver using the following command:
    arduino

    sudo apt-get install php7.4-sqlite3
    

    Replace php7.4 with your PHP version if it’s different.

    Check Database Configuration: Ensure that your Laravel project is correctly configured to use SQLite as the database driver. You can find the database configuration in the config/database.php file. Make sure the default connection is set to ‘sqlite’ and the database key points to a valid SQLite database file.

    Run Migration: If you haven’t run database migrations yet, you may encounter this error when attempting to access routes that require database connectivity.

    Run the following command to migrate your database:

    php artisan migrate
    

    Clear Cache: Sometimes, cached configurations can cause issues. Try clearing the Laravel cache by running:

    php artisan cache:clear
    

    After performing these steps, try running php artisan serve again and check if the issue persists. If you’re still encountering problems, double-check your environment configuration and ensure that SQLite is properly set up and accessible to your Laravel application.

    Login or Signup to reply.
  2. It’s probably the problem of an extension not activated on php.ini

    You should go to your php.ini commonly C:phpphp.ini on windows or /etc/php/php.ini on linux and edit the file

    you should remove the semicolon at extension=pdo_sqlite , extension=pdo_mysql or
    extension=mysqli depending on what database are you running your app on.

    Enable them (again, by removing the semicolon) and see if this works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search