Setting Up SQLite In The Laravel Application
  • Services
    • What We Do
    • How We Collaborate
    • Product UI/UX
    • Agile Team
    • Software Development
    • Fixed Price
    • Creative Growth
    • Staff Augmentation
  • Our Work
    • Case Studies
    • Client Stories
  • About
  • Contact
  • Blog
  • Careers
Let's Talk
Back
Development
5 min read

Setting Up SQLite in a Laravel Application

  • rdbr-blogs
  • Author
    rdbr-blogs
  • Published
    June 14, 2022

First of all, what is SQLite?

SQLite is one of the representatives of SQL database systems best known for its simpleness and high speed. Therefore, SQLite is an excellent choice for middle-sized projects. It is small, flexible, fast, and quite simple to set up in our application.

SQLite is not a Client/Server RDBMS (Relational Database Management System); it is built-in in our application, and the data is being retrieved/stored/modified during our application process. 

With Client/Server RDBMS, our application is a separate process, and the database is another. That relation means that the connection between the database is basically a dialogue and intercommunication between computer processes. Communication within the computer processes requires extra resources and usually causes delays. In that respect, SQLite is more efficient. 

However, SQLite has its drawbacks. At any given moment, SQLite can only make one entry. So if the traffic for database entries is high, it slows down. However, fetching data from the database can be divided into different streams. Therefore, it is essential to consider how much and what kind of workload our application will have and choose the database accordingly. 

Prerequisites for the setting up SQLite in Laravel (Ubuntu, WSL)

To use SQLite, we need to install the appropriate package:

sudo apt install sqlite3

You also need to install the PHP extension for PHP to communicate with the SQLite database.

sudo apt install php-sqlite3

SQLite configuration in Laravel

One of the drivers of Eloquent is SQLite; therefore, setting up SQLite in Laravel means just changing the .env file. 

The standard database configuration in a .env file looks like this:

The only thing we need from here is DB_CONNECTION. We can delete the rest because since SQLite is a one-file database, it doesn’t need a database name, user, or password, nor does it have any user privileges. 

Put sqlite in DB_CONNECTION and delete the rest of the parameters from .env:

You will also need to create an empty file in the database folder and name it as database.sqlite because generally, Laravel searches the SQLite file at that address:

If you want to have an SQLite database (file) on the other address, you should tweak the config/database.php and put the desired name and address of the file:

And that’s it, 

Happy Querying 📕

Written by: Giorgi Giunashvili

Translated by: Keti Getiashvili

Meet the authors

We are a 200+ people agency and provide product design, software development, and creative growth marketing services to companies ranging from fresh startups to established enterprises. Our work has earned us 100+ international awards, partnerships with Laravel, Vue, Meta, and Google, and the title of Georgia’s agency of the year in 2019 and 2021. 

Contact Us

Get in touch

Nuki Zhgenti

Business development manager

Book a call

Shermadin Osadze

Business development manager

Book a call

Hey!

We are an official Laravel and Vue partner agency from Tbilisi, Georgia.

Need help with software development or extending your team? You’re in the right place.

Let’s make cool things happen 🚀

reach out
Prerequisites for the setting up SQLite in Laravel (Ubuntu, WSL)
SQLite configuration in Laravel
Meet the authors
Get in touch
Next Post
The Significance of Context in UI/UX

Recent Posts

Development
10 min read

Recapping Taylor Otwell's Key Points from Laracon 2023

Finally, the much-awaited Laracon 2023 event was held...

Read More
Development
8 min read

All You Need To Know About Laravel Herd: Pros & Cons

While we couldn’t attend it in person, we’ve...

Read More
Development
10 min read

Tools We Use While Managing Remote Development Team At Redberry

We recently published an article where we talked...

Read More
  • Follow us
    Fb. /  Lk.  /   Be.
  • Have a project in mind?
    hello@redberry.ge
  • Looking for an opportunity?
    joinus@redberry.ge
© 2021, Redberry - Digital Transformation Agency
All right reserved.