Two modes
Start fresh or scaffold existing
Whether you're spinning up a new project or inheriting a legacy schema, Capyrel adapts to where you are.
New project
Describe it, build it
Start from plain English. Capyrel parses your description, matches archetypes, proposes fields interactively, then writes models + migrations.
php artisan capyrel:new
Existing database
Scaffold from your schema
Point Capyrel at your running database. It reads foreign keys, detects relationships, generates controllers and routes — with a health check built in.
php artisan model:scaffold
Quick start
New project wizard
Run one command. Capyrel detects your stack, parses your description, proposes fields in an interactive table, and writes everything.
php artisan capyrel:new
New Project Wizard — models + migrations, zero friction
Laravel 12.x · PHP 8.3 · Scout
Describe your project (or list your models):
> a blog platform with posts, tags, authors, and comments
Detected entities: Post, Tag, Author, Comment
── Post ───────────────────────────────────────────────
Archetype matched: post
┌─────────────┬──────────────────┬──────────────┐
│ Field │ Type │ Flags │
├─────────────┼──────────────────┼──────────────┤
│ title │ string │ — │
│ slug │ string │ unique │
│ body │ text │ nullable │
│ published_at│ timestamp │ nullable │
│ is_published│ boolean │ default=false│
│ user_id │ foreignId → users│ — │
└─────────────┴──────────────────┴──────────────┘
What would you like to do with Post?
> Confirm — looks good
✔ Wrote app/Models/Post.php
✔ Wrote database/migrations/2026_05_24_create_posts_table.php
php artisan migrate
php artisan model:scaffold
Quick start
Scaffold an existing database
Capyrel reads your schema, maps every relationship, runs a health check, then writes model methods, controllers, and routes.
php artisan model:scaffold
Detected relationships:
User
├── hasMany ──▶ Post [posts.user_id]
├── hasOne ──▶ Profile [profiles.user_id]
└── belongsToMany ──▶ Role [pivot: role_user]
Post
├── belongsTo ──▶ User [posts.user_id]
└── hasMany ──▶ Comment [comments.post_id]
⚕ Health check — 1 warning
⚠ [Post] Missing index on posts.user_id — full table scan risk
↳ Add: $table->index('user_id') in the migration
Write relationship methods into model files? [yes]
Generate / update controller files? [yes]
Write resource routes to routes/web.php? [yes]
✔ Capyrel scaffold complete.
4 model method(s) added · 2 controller(s) touched
What Capyrel generates
Everything from one schema
One command fan-out — models, migrations, controllers, tests, API specs, TypeScript interfaces, and more.
🏗️
Models & Migrations
Fillable arrays, casts, relationships, and SoftDeletes traits — all written for you with archetype-matched field types.
capyrel:new · model:scaffold
🔌
Controllers & Routes
Paginated index with search, eager loading, dual JSON/view responses, and restore/forceDelete for soft-delete models.
model:scaffold
📡
API Resources
N+1-proof resources using whenLoaded() — auto-generated for every relationship detected in your schema.
model:resources
🛡️
Form Requests
Validation rules derived from column types: varchar → max:255, FK → exists, unique index → Rule::unique, email column → email rule.
model:requests
🧪
Pest Tests
Relationship tests for every HasMany, BelongsTo, BelongsToMany — including attach/sync tests for pivot tables.
model:tests
📋
Factories & Seeders
Column-aware: email → fake()->email(), *_at → fake()->dateTime(), FK → related factory. No manual wiring.
model:factory · model:seed
📝
OpenAPI & Postman
Full OpenAPI 3.0 YAML spec and Postman collection — ready to import, covering every generated route.
capyrel:openapi · capyrel:postman
🟦
TypeScript Types
TypeScript interfaces generated from your schema — ship to your frontend with one command.
capyrel:typescript
⚡
Architecture Layer
Repository, Service, DTO classes; state machines; policies; enums; observers; Livewire components; broadcast events.
model:architecture · model:state-machine
Project examples
Real projects in minutes
From a simple blog to a SaaS with teams and subscriptions — Capyrel scales with your complexity.
php artisan capyrel:new
# > a blog with posts, tags, authors, and comments
php artisan migrate
php artisan model:scaffold
php artisan model:resources # API Resources
php artisan model:tests # Pest tests
php artisan capyrel:openapi # OpenAPI 3.0
php artisan capyrel:new
# > Product, Order, Customer, Review, Coupon
php artisan migrate
php artisan model:scaffold
php artisan model:factory # factories
php artisan capyrel:typescript # TS types
php artisan capyrel:postman # Postman
php artisan capyrel:new
# > User, Team, Plan, Subscription, Invoice
php artisan migrate
php artisan model:state-machine Subscription
php artisan model:permissions
php artisan model:broadcast User
php artisan capyrel:new
# > Article, Author, Publication, Tag
php artisan model:scaffold --models --controllers
php artisan model:resources
php artisan model:requests
php artisan capyrel:openapi
Command reference
Every command at a glance
30+ artisan commands organized by what they do — run any one independently or chain them.
New project wizard
capyrel:new
Interactive wizard — describe your project, review fields, write models + migrations
capyrel:new --force
Skip all confirmations
Scaffolding
model:scaffold
Full scaffold from existing database: relationships, controllers, routes
model:scaffold User
Scaffold one model only
model:scaffold --dry-run
Preview what would be written — writes nothing
model:scaffold --connection=pgsql
Target a specific database connection
model:map --format=mermaid
ASCII tree or Mermaid diagram of all relationships
API layer
model:resources
API Resources with whenLoaded() for every relationship — N+1-proof
model:requests
Form Requests with column-derived validation rules
model:tests
Pest relationship tests for every model
model:factory / model:seed
Column-aware factories and seeder classes
Architecture
model:architecture Post
Repository, Service, DTO pattern for a model
model:state-machine Order
State machine: pending → processing → shipped → delivered
model:policy
Policy class with index/view/create/update/delete/restore
model:enum Post
PHP enums from string columns with detectable patterns
model:broadcast Post
Created/Updated/Deleted events + channel classes
model:livewire Post
PostIndex + PostForm Livewire components
Contract generation
capyrel:openapi
OpenAPI 3.0 YAML spec — ready for Postman/Swagger
capyrel:typescript
TypeScript interfaces for every model
capyrel:postman
Postman collection JSON for all routes
capyrel:graphql
GraphQL schema SDL
Safety & ops
capyrel:safe-migrate --check
Scan migrations for risk — never runs, just reports
capyrel:health-controller
Generates /api/health endpoint with DB + cache checks
capyrel:audit
Full schema health report without writing anything
capyrel:watch
Watch mode — auto-updates models when migrations change
capyrel:fullstack
One command: scaffold + routes + tests
Schema intelligence
Built-in health check
Every scaffold run includes a schema audit. Capyrel catches 12 categories of issues before they hit production.
| Check | What it finds |
| N+1 risk | Relationship access without eager loading |
| Missing index | FK columns with no index — full table scan potential |
| Orphan FK | *_id columns pointing to tables that don't exist |
| Inverse missing | One-sided relationship — A→B defined, B→A not |
| Naming conflict | Generated method name clashes with existing method |
| Soft-delete drift | deleted_at column without SoftDeletes trait |
| Eager load depth | hasManyThrough chains 3+ levels deep |
| Circular dependency | Self-referential eager load that would loop |
| Cascade risk | FK with no ON DELETE rule |
| Fillable drift | $fillable fields that don't exist in the table |
| Morph registry | morphTo without Relation::morphMap() |
| Dead relationship | Defined but never referenced anywhere |
Validation intelligence
Rules derived from your schema
Capyrel reads column types, constraints, and naming conventions to infer Form Request validation rules automatically.
// StorePostRequest.php
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:255'],
'body' => ['required', 'string'],
'slug' => ['required', 'string', Rule::unique('posts', 'slug')],
'user_id' => ['required', 'integer', 'exists:users,id'],
];
}
varchar(255)→max:255
nullable→removes required
*_id FK→exists:table,id
unique index→Rule::unique()
column email→email rule
column *_url→url rule
Database support
Works with your database
Full schema introspection across MySQL, PostgreSQL, SQLite, and MongoDB — FK detection and index scanning included.
| Database | Schema reading | FK detection | Index detection |
| MySQL / MariaDB | ✓ | ✓ | ✓ |
| PostgreSQL | ✓ | ✓ | ✓ |
| SQLite | ✓ | ✓ | ✓ |
| MongoDB | ✓ document sampling + migration fallback | ✓ convention | ✓ |
Ready to ship your Laravel schema?
One composer command, and Capyrel handles the rest — models, migrations, controllers, tests, and full API documentation.
composer require julio/capyrel