Connect your laravel application to Sqlite DB

Connect your laravel application to Sqlite DB

Aug 02, 2019 / Ramesh Mhetre

I've come across this scenario of connecting to Sqlite database, mainly when quickly prototyping something with laravel.

As usual, its a quick thing with your laravel application. It is also mentioned in the official docs here.

Quick steps:

  • Create your DB file (yourdb.sqlite) file anywhere within your application. I prefer to create it in storage folder such as touch database/database.sqlite.
  • Change your .env file like:
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite

To enable foreign key constraints for SQLite connections, you should add the foreign_key_constraints option to your config/database.php configuration file:

'sqlite' => [
    // ...
    'foreign_key_constraints' => true,
],



Similar Articles

How to do multi tenant application with Laravel

How to do multi tenant application with Laravel

How to do multi tenant application with Laravel. Have single laravel setup for multiple applications
Read more...
What is new to Laravel 6?

What is new to Laravel 6?

Today Laravel 6 has finally officially released. Let's have a detailed look at what is changing in Laravel 6.
Read more...
Laravel v6 & Laravel Vapor is going to release soon 🚀

Laravel v6 & Laravel Vapor is going to release soon 🚀

Laravel v6 is is releasing soon. Serverless laravel is next big thing in laravel community!
Read more...