A Node.js package that automatically generates Entity-Relationship Diagrams (ERD) for Laravel applications.
npm install @priom7/laravel2erd
- 📊 Automatically analyze Laravel models to generate ERD diagrams
- 🔍 Detect table names, attributes, and data types
- 🔄 Map relationships between models
- 🖼️ Interactive web viewer with zoom controls
- 💾 Export diagrams as SVG
After installation, you can generate an ERD diagram for your Laravel project:
# Generate an ERD with default settings
npx laravel2erd
# Customize the output
npx laravel2erd --output public/docs/erd --models app/Models --title "My Project ERD"
Once generated, you can view your ERD diagram at:
http://your-app-url/laravel2erd
-o, --output <directory>
: Output directory for ERD (default:public/laravel2erd
)-m, --models <directory>
: Models directory (default:app/Models
)-r, --relations
: Include relationships (default:true
)-t, --title <title>
: Diagram title (default:Laravel ERD Diagram
)
Laravel2ERD analyzes your Laravel model files to extract:
- Table information: Names and structure
- Attributes: From fillable arrays and casts
- Relationships: Including one-to-one, one-to-many, and many-to-many
It then generates a Mermaid-based diagram that visualizes your database structure.
// app/Models/User.php
class User extends Model
{
protected $fillable = [
'name', 'email', 'password',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
public function posts()
{
return $this->hasMany(Post::class);
}
}
Will be represented in the ERD diagram with proper relationships and attributes.
MIT License - see LICENSE file for details.
Created by priom7