Laravel Database: Adding a database

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


We’re using Laravel in a very basic form, without any database.

Now I want to set up a database and configure Laravel to use it.

After we’ve configured the database, I’ll show you how to use forms to accept user input and store data in the database, and how to visualize this data.

I’ll also show you how you can use data from the database with dynamic routes.

The easiest way to use a database is by using SQLite.

SQLite is just a file hosted in your site, no special setup needed.

Open the .env file, and instead of the default configuration

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

add

DB_CONNECTION=sqlite

Laravel will automatically create a SQLite database in database/database.sqlite the first time you run a migration.

Lessons in this unit:

0: Introduction
1: ▶︎ Adding a database
2: How to use migrations to create and modify the database schema
3: Using forms to accept user input and store it into the database
4: Adding the form at the bottom of the list
5: Allow users to delete dogs from the list
6: Connecting a database to Laravel
7: How to use migrations to create and modify the database schema
8: Using forms to accept user input and store it into the database