Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nfpms:
homepage: https://phi-orm.vercel.app
maintainer: Clancy <a7mdmo2mn@gmail.com>
description: "Phi - A compile-time ORM for Go mirroring the Prisma developer experience."
license: MIT
license: Apache-2.0
formats:
- deb
- rpm
Expand Down
61 changes: 53 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
# Phi

Phi is a **compile-time ORM for Go** that mirrors the Prisma developer experience. It parses your `schema.prisma` file and generates a type-safe client with zero reflection at runtime.
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.

## Features
[Documentation Website](https://phi-orm.vercel.app) | [pkg.go.dev](https://pkg.go.dev/github.com/voidclancy/phi)

- **Compile-time type safety** - queries, predicates, and results are generated from your schema, so mistakes fail at build time, not runtime.
- **Zero runtime overhead** - no reflection, no sidecars. Everything compiles down to standard `database/sql`.
- **Prisma-style schema** - keep writing `schema.prisma` and get types, builders, and migrations generated from it.
- **Multi-provider** - PostgreSQL, SQLite (for now).
- **Schema migrations** - generate and apply migrations straight from the CLI, with optional embedded migrations.
## Key Features

* **Compile-time Type Safety**: Queries, predicates, and selections fail at build time if invalid.
* **Zero Reflection**: Compiles down to standard `database/sql` calls for maximum query execution speed.
* **Prisma Schema DX**: Use your existing `schema.prisma` models, 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.

## Installation

Install the Phi CLI tool:

```bash
go install github.com/voidclancy/phi@latest
```

## Quick Start

1. Initialize your configuration file:

```bash
phi init
```

2. Generate your type-safe Go client:

```bash
phi generate
```

3. Query your database:

```go
client, err := phi.NewClient(phi.WithDSN(os.Getenv("DATABASE_URL")))
if err != nil {
log.Fatal(err)
}
defer client.Close()

u, err := client.User.FindUnique(
user.Email.EQ("user@example.com"),
).Exec(ctx)
```

## Documentation

[https://phi-orm.vercel.app](https://phi-orm.vercel.app)
Full guides, API references, CLI commands, and hooks documentation are available on the documentation website:

[https://phi-orm.vercel.app](https://phi-orm.vercel.app)

## License

[Apache 2.0 License](LICENSE)
13 changes: 12 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
.PHONY: build build-prod run test coverage cover-html install db-up db-down db-clean bi fmt fmt-check tidy tidy-check vulncheck vet integration-gen integration-test bench bench-sqlite bench-pg bench-all race lint test-sqlite test-pg test-dbs ci-local
.PHONY: build build-prod run test coverage cover-html install db-up db-down db-clean bi fmt fmt-check tidy tidy-check vulncheck vet integration-gen integration-test bench bench-sqlite bench-pg bench-all race lint test-sqlite test-pg test-dbs ci-local index-pkg

index-pkg:
@TAG=$$(git describe --tags --abbrev=0 2>/dev/null); \
if [ -z "$$TAG" ]; then \
echo "No git tag found. Please push a tag first (e.g. git tag v0.1.0 && git push origin v0.1.0)"; \
exit 1; \
fi; \
echo "Indexing $$TAG on pkg.go.dev via proxy.golang.org..."; \
curl -s https://proxy.golang.org/github.com/voidclancy/phi/@v/$$TAG.info; \
echo ""; \
echo "Package $$TAG submitted to pkg.go.dev"

bi: build install

Expand Down
Loading