Prisma SQLite Setup
SQLite is the easiest way to get started with Prisma PHP. It requires no external server, as the database is simply a file within your project structure.
Configuration Workflow
Follow these steps to initialize your local database.
-
1
Set provider to sqlite in
schema.prisma. -
2
Define the file path in your
.envfile (relative to project root). - 3 Run migrations to create the database file.
-
4
Generate Prisma Classes:
npx ppo generate
Schema Configuration
Update your /prisma/schema.prisma to use the SQLite provider.
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
}
Environment Variables
Define the location of your database file. The path is relative to the root of your project.
DATABASE_URL="file:./prisma/dev.db"
Understanding Relative Paths
The file: path is relative to your Project Root (where the .env file is located).
-
file:./dev.db
Creates DB in the project root. -
file:./prisma/dev.db
Creates DB inside the prisma folder (Recommended).
Absolute Paths
If you need to store the database outside the project directory, you can use an absolute path:
Ready to Migrate?
Your SQLite environment is configured. Run the migration command to generate the database file and the client.
Go to Prisma Command