From the docs:
DB_DATABASE=/absolute/path/to/database.sqlite
You need to put the full path to the database file, not just 'database/database.sqlite'.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
As I understand the database connection starts as follow...
In file database.php, Laravel will check if a variable called DB_CONNECTION exists in the .env file, if it does it will use the values from the .env file, if NOT it will use the values in the database.php, correct? Simple enough.
If the above statement is true, can you please confirm that my steps below are correct?
So, in theory and according to the documentation if we want to use Sqlite in a new/fresh Laravel project this is what we would do...
Create new project
Create the sqlite database file (database/database.sqlite)
Go to the .env file and change the DB_CONNECTION and the DB_DATABASE values as follow...
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database/database.sqlite
DB_USERNAME=homestead
DB_PASSWORD=secret
Migrate database php artisan migrate
Done.
In theory at this point we should have a working DB, correct?
... But not on my case, I get Database (database/database.sqlite) does not exist. error.
Documentation REF : https://laravel.com/docs/5.2/database
Let me clarify that I'm able to connect to the database but NOT using the method described above, what I did is deleted the DB_CONNECTION and the DB_DATABASE variables from the .env file and specified sqlite in the database.php file ('default' => env('DB_CONNECTION', 'sqlite'),) and it worked but the fact that what is recommended in the docs doesn't work is bothering me.
BTW - I'm on a Mac and used php artisan serve to view my pages, I'm not sure if that matters.
No. That would be a relative path. Your absolute path would be something like /home/username/projects/app/database/database.sqlite. You need the full path to the file.
Please or to participate in this conversation.