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.
- 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.
- 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.
- 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.
Nandini is a Web Developer and a blogger who loves tinkering with new technologies, frameworks and devices. When not in front of her computer she likes to travel, read and spend time gardening.