Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lornstil's avatar

problem with creating a sqlite database

I am running Laravel Herd on my Windows system. During the setup of my project, I selected "sqlite" as my database. However, when I try to verify this using the command "php artisan db:show", I get an error that indicates a dependency conflict between doctrine/dbal and carbonphp/carbon-doctrine-types via nesbot/carbon. I believe I resolved this conflict with "composer require doctrine/dbal."

However, when I tried "php artisan db:show" again, I get an error that indicates that Laravel is attempting to connect to a SQLite database located at \Herd\laracast-app\database\database.sqlite, but it cannot find the database file at the specified path. Upon further investigation, I found that there was no database.sqlite file present at that file path.

I tried creating my own "database.sqlite" file and placing it in the database folder, but I continued to receive the same error that the file database.sqlite does not exist.

I would appreciate any advice on how to resolve this issue or how to correctly create a database.sqlite file.

0 likes
1 reply
LaryAI's avatar
Level 58

It sounds like you're on the right track by creating the database.sqlite file manually. Here's a step-by-step guide to ensure you're doing it correctly and to resolve the issue:

  1. Create the SQLite Database File: First, make sure you're in the root directory of your Laravel project. Then navigate to the database directory and create an empty file named database.sqlite. You can do this using the command line with the following commands:

    cd database
    type nul > database.sqlite
    

    Or, if you prefer using a file explorer, simply create a new file in the database directory and name it database.sqlite.

  2. Update the .env File: Next, ensure that your .env file is configured to use the SQLite database. Open the .env file in your project's root directory and set the DB_CONNECTION to sqlite. Also, make sure to comment out or remove the other database configuration settings like DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD, as they are not needed for SQLite. Your .env file should include something like this:

    DB_CONNECTION=sqlite
    # DB_HOST=127.0.0.1
    # DB_PORT=3306
    # DB_DATABASE=laravel
    # DB_USERNAME=root
    # DB_PASSWORD=
    
  3. Configure the Database Configuration File: Open the config/database.php file and ensure that the sqlite connection is set up correctly. It should look something like this:

    'sqlite' => [
        'driver' => 'sqlite',
        'url' => env('DATABASE_URL'),
        'database' => env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' => '',
        'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
    ],
    

    The database_path('database.sqlite') function should correctly reference the path to your SQLite database file.

  4. Clear Configuration Cache: Sometimes Laravel caches the configuration and does not recognize changes. Clear the configuration cache by running the following command:

    php artisan config:clear
    
  5. Run the php artisan db:show Command Again: Now that you have created the database.sqlite file and updated your configuration, try running the php artisan db:show command again to see if the issue is resolved.

If you follow these steps and still encounter issues, double-check the file permissions for the database.sqlite file to ensure that Laravel has the necessary permissions to read and write to the file. If the problem persists, consider checking the Laravel logs (located in storage/logs) for more detailed error messages that can help in troubleshooting the issue.

Please or to participate in this conversation.