Laravel Ecosystem

Capyrel

Schema intelligence for Laravel. Describe your project in plain English — or point it at an existing database — and get models, migrations, controllers, routes, API specs, tests, and more.

composer require julio/capyrel click to copy
Laravel 11 & 12 PHP 8.2+ MySQL PostgreSQL SQLite MongoDB

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

New project wizard

Run one command. Capyrel detects your stack, parses your description, proposes fields in an interactive table, and writes everything.

shell
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
next steps
php artisan migrate
php artisan model:scaffold   # controllers + routes

Scaffold an existing database

Capyrel reads your schema, maps every relationship, runs a health check, then writes model methods, controllers, and routes.

shell
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

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

Real projects in minutes

From a simple blog to a SaaS with teams and subscriptions — Capyrel scales with your complexity.

Blog platform
5 models · API Resources · OpenAPI spec · Pest tests
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
E-commerce store
7 models · Factories · TypeScript types · Postman
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
SaaS with teams
State machine · Permissions matrix · Broadcast events
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
REST API only
Resources · Requests · OpenAPI · TypeScript · Postman
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

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

Built-in health check

Every scaffold run includes a schema audit. Capyrel catches 12 categories of issues before they hit production.

CheckWhat it finds
N+1 riskRelationship access without eager loading
Missing indexFK columns with no index — full table scan potential
Orphan FK*_id columns pointing to tables that don't exist
Inverse missingOne-sided relationship — A→B defined, B→A not
Naming conflictGenerated method name clashes with existing method
Soft-delete driftdeleted_at column without SoftDeletes trait
Eager load depthhasManyThrough chains 3+ levels deep
Circular dependencySelf-referential eager load that would loop
Cascade riskFK with no ON DELETE rule
Fillable drift$fillable fields that don't exist in the table
Morph registrymorphTo without Relation::morphMap()
Dead relationshipDefined but never referenced anywhere

Rules derived from your schema

Capyrel reads column types, constraints, and naming conventions to infer Form Request validation rules automatically.

php — auto-generated
// 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
nullableremoves required
*_id FKexists:table,id
unique indexRule::unique()
column emailemail rule
column *_urlurl rule

Works with your database

Full schema introspection across MySQL, PostgreSQL, SQLite, and MongoDB — FK detection and index scanning included.

DatabaseSchema readingFK detectionIndex 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