Commands Reference

All available artisan commands provided by the package.

model-analyzer:analyze

Scans all Eloquent models and validates relationships, columns, indexes, and constraints.

Option Description Default
--path Directory to scan for models app/Models
--format Output format (text or json) text
--model Analyze a specific model only all
--strict Return exit code 1 on any issue false
$ php artisan model-analyzer:analyze

Scanning models in: app/Models
Found 6 models

Analyzing relationships...

  User .............. OK    (4 relationships, no issues)
  Post .............. WARN  (missing index on `editor_id`)
  Comment ........... WARN  (Reaction inverse missing)
  Tag ............... OK    (1 relationship, no issues)
  Order ............. OK    (1 relationship, no issues)
  Product ........... ERROR (foreign key column `category_id` does not exist)

──────────────────────────────────────────────────────
 Issues found: 1 error, 2 warnings
 Health Score: 62 / 100
──────────────────────────────────────────────────────

  [ERROR]   Product::belongsTo(Category)
            → Column `category_id` not found on `products` table

  [WARNING] Post
            → Column `editor_id` has no index (performance risk)

  [WARNING] Comment::hasOne(Reaction)
            → No inverse relationship found on Reaction model

model-analyzer:health

Generates a weighted health score (0-100) for your model layer across five categories.

62 /100

FAIR

$ php artisan model-analyzer:health

 Model Health Report
 ═══════════════════

 Score: 62/100  ██████░░░░  FAIR

 Breakdown:
   Inverse relationships    30/30
   No circular deps         30/30
   Column existence         10/20  (1 missing column)
   Foreign key indexes       8/10  (1 unindexed FK)
   Foreign key constraints   4/10  (missing FK definition)

 Recommendations:
  1. Add `category_id` column to `products` table or remove the Category relationship
  2. Add an index to `posts.editor_id`
  3. Define a Reaction model or remove the hasOne from Comment

model-analyzer:visualize

Generates a standalone HTML file with an interactive D3.js force-directed graph of your model relationships.

Option Description Default
--output Output file path for the generated HTML model-relationships.html
--models Comma-separated list of model names to include all
--erd Generate an Entity Relationship Diagram with table boxes, columns, and crow's foot cardinality false
--format Output format: html (interactive, D3.js) or svg (static, embeddable) html
$ php artisan model-analyzer:visualize

Analyzing model relationships...

Graph generated: model-relationships.html
  6 models, 16 relationships, health score: 62/100
$ php artisan model-analyzer:visualize --erd

Analyzing model relationships...

ERD generated: model-erd.html
  6 models, 16 relationships, health score: 62/100
$ php artisan model-analyzer:visualize --format=svg

Analyzing model relationships...

Graph generated: model-relationships.svg
  6 models, 16 relationships, health score: 62/100

model-analyzer:list-models

Lists all discovered Eloquent models with optional relationship counts.

Option Description Default
--with-relationships Show relationship count per model false
--path Directory to scan for models app/Models
$ php artisan model-analyzer:list-models --with-relationships

 Discovered Models
 ═════════════════

  Model      Namespace                   Relationships
  ─────────────────────────────────────────────────────
  User       App\Models\User             4
  Post       App\Models\Post             4
  Comment    App\Models\Comment          3
  Tag        App\Models\Tag              1
  Order      App\Models\Order            2
  Product    App\Models\Product          2

 Total: 6 models, 16 relationships