I was trying to use sqlite database in a Laravel project (I am using version 5.4, but I think this is relevant for other versions too) and I found this issue.

I had my database.sqlite file in the database directory.

  1. In the .env file if I put DB_DATABASE=database/database.sqlite, my migration works and I can connect using tinker. But I am not able to connect to the database from my application and getting the following error – Database (database/database.sqlite) does not exist.
  2. If I put DB_DATABASE=../database/database.sqlite, the opposite happens, i.e. I can connect from my application but migration or tinker doesn’t work.
  3. To get it right both ways there are two ways you can go –
    • You can put the absolute path in the .env file.
    • Or you can delete the DB_DATABASE attribute from your .env file, if the name of your file is database.sqlite it should work as is, if you have a different name change it inside config/database.php and it should work.
Laravel: Database (database/database.sqlite) does not exist
Tagged on: