Prisma PHP ORM
Prisma PHP ORM is a modern database toolkit inspired by Prisma for TypeScript—but built specifically for PHP. It allows you to model your database schema in a simple declarative syntax and instantly generate a fully-typed PHP client to interact with your database using intuitive, type-safe queries.
❖ Schema-First
Model your data using @relation, @default, and @unique in a declarative schema.prisma file.
⚡ Fully Typed Client
Auto-generated PHP Client with intelligent code completion for models, fields, and relations.
🛠 Powerful CLI
Built-in commands to migrate, generate, push, and reset your database.
🔍 Fluent API
Expressive methods like findMany, create, and update using clean, fluent arrays.
Enhanced Developer Experience
For the best experience, we highly recommend installing the official VS Code extension. It bridges the gap between your schema and your PHP code.
-
✔
Auto-completion for
where,select, andinclude. - ✔ Real-time validation of field names and types.
- ✔ Context-aware filtering for nested relations.
- ✔ Inline diagnostics for invalid types.
- ✔ Hover previews for model definitions.
- ✔ Jump-to-definition (F12) support.
Quick Start Workflow
1. Define your Schema
Edit your schema.prisma file to define your models.
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
}
2. Generate the Client
Run the generator command to create the PHP classes.
npx ppo generate
3. Query your Data
Use the generated client in your application logic.
// Create a new user
$user = $prisma->user->create([
'data' => [
'name' => 'Alice',
'email' => 'alice@prisma.io',
],
]);
// Find all users
$users = $prisma->user->findMany([
'include' => ['posts' => true],
]);