Laravel provides several database connection providers like sqlitemysqlpgsqlsqlsrv. In this tutorial, I will show you how to connect sqlite database in laravel. If you do not know laravel sqlite setup, then this how to connect to sqlite database in laravel tutorial is for you. If you are facing error like laravel sqlite database does not exist, the hope this tutorial will help you to solve this issues.

You have already known that laravel provides a .env file in the project root path. We can connect any database configuration in laravel using this file. So let's see the example code of how to connect to sqlite database in laravel.

.env

DB_CONNECTION=sqlite
DB_HOST=127.0.0.1

 

And now we have to create a database.sqlite file in the database folder. So the file path will be database/database.sqlite Now create it. Now run php artisan migrate and see the below output.

MIGRATE
  INFO  Running migrations.
  2014_10_12_000000_create_users_table ................................. 96ms DONE   
  2014_10_12_100000_create_password_resets_table ........................ 9ms DONE   
  2019_08_19_000000_create_failed_jobs_table ............................ 9ms DONE   
  2019_12_14_000001_create_personal_access_tokens_table ................ 11ms DONE

 

Read also: How To Connect PostgreSQL Database In Laravel?

 

Conclusion

I have tried to discuss the clear concept of laravel sqlite setup. Now we know how to connect sqlite database in laravel. Hope this how to connect to sqlite database in laravel tutorial will help you.