Phi is a compile-time ORM for Go that mirrors the Prisma developer experience. It parses your schema.prisma file and generates a strongly-typed Go database client with zero runtime reflection.
Documentation Website | pkg.go.dev
- Compile-time Type Safety: Queries, predicates, and selections fail at build time if invalid.
- Zero Reflection: Compiles down to standard
database/sqlcalls for maximum query execution speed. - Prisma Schema DX: Use your existing
schema.prismamodels, enums, native attributes, and relations. - Declarative Migrations: Integrated forward-only migration engine powered by Atlas DDL diffing.
- Extension Hooks: Intercept and mutate CRUD operations via middleware closures.
- Multi-Provider: Native support for PostgreSQL and SQLite.
Install the Phi CLI tool:
go install github.com/voidclancy/phi@latest- Initialize your configuration file:
phi init- Generate your type-safe Go client:
phi generate- Query your database:
db, err := phi.Open("sqlite3",
"file:memdb1?mode=memory&cache=shared&_pragma=foreign_keys(1)&_time_format=sqlite")
if err != nil {
log.Fatalf("failed to open db: %v", err)
}
defer db.Close()
u, err := db.User.FindUnique(
user.Email.EQ("user@example.com"),
).Exec(ctx)Full guides, API references, CLI commands, and hooks documentation are available on the documentation website: