By default, Foal uses SQLite in every new application, as it does not require any installation. If you want to continue using it in this tutorial, you can skip this section and go to the next page.
First, install MySQL (or Postgres) driver.
config/default.json file and update the
database section as follows. If your database is PostgreSQL, change the
type value to
This file is the main configuration file for the application and is used as the basis for whatever environment the application is running in.
env(*) tells the configuration system to get the value from the given environment variable. If it does not exist, Foal will try to read it from a
Create a new
.env file in the root of
backend-app and provide the database credentials.
Restart the development server. The application is now connected to your database.
You could have specified all the database connection options directly in the
default.jsonfile but this is considered bad practice.
Configuration files are usually committed to version control and it is recommended not to commit files containing sensitive information.