🎓 A1Learner
🔍
0 of 50 lessons completed

Laravel Database Setup

Database setup is the config that tells Laravel where your data lives. The .env file holds the database settings for the app.

The database lines

This line picks sqlite as the driver.

DB_CONNECTION=sqlite

The database file

Sqlite keeps the data in this file.

database/database.sqlite

Create the tables

The command runs and reports each table.

php artisan migrate

Example

DB_CONNECTION=sqlite

php artisan migrate

Key points

  • Database config: the settings that pick the database driver and file.
  • Use DB_CONNECTION to pick the driver, such as sqlite.
  • Use a sqlite file for a small app with no database server.
  • Use php artisan migrate to create the tables.

In this example, the .env file sets sqlite as the driver. The migrate command builds the tables. Each table line ends with DONE. Database setup is the config that tells Laravel where your data lives.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which .env line picks sqlite as the database driver?