How to make SQLite work in Laravel How to make SQLite work in Laravel sqlite sqlite

How to make SQLite work in Laravel


Short Solution

Though not answering the question, the way to fix "Database not found" issue is to replace the following line in database.php:

'database' => env('DB_DATABASE', database_path('database.sqlite')),

with

'database' => database_path('database.sqlite'),


By using the relative path, migrations will fail because they use project directory as root directory...

To correct everything, I suggest setting:

   DB_DATABASE=database\database.sqlite

and tweaking the sqlite connections in config/database.php as follows:

  'database' => env('DB_DATABASE/..', database_path('database.sqlite')),

Original Answer

The .env file should contain this:

   DB_DATABASE=..\database\database.sqlite

With some testing you can verify that the link included in DB_DATABASEis relative to the 'public' directory (at least on my Windows machine). That's why we should introduce ..\ before your link.

And of course, using an absolute link should do it too:

   DB_DATABASE=D:\www\project\database\database.sqlite 

as @Josh suggests


Complementing the awnser by our friend @alexander-lomia

Change:

'database' => env('DB_DATABASE', database_path('database.sqlite'))

To:

'database' => database_path(env('DB_DATABASE'))

in database.php

:)