msme/laravel-bloom
最新稳定版本:v1.0.1
Composer 安装命令:
composer require msme/laravel-bloom
包简介
Instant, intelligent development data for Laravel applications
README 文档
README
Instant, intelligent development data for Laravel applications.
Laravel Bloom automatically generates rich, realistic, and relational datasets directly from your database schema — and gives you a beautiful visual interface to explore it.
No factories. No manual seeders. No configuration required.
✨ Why Laravel Bloom?
When building features, testing UI flows, or demoing your application, empty databases slow you down.
Laravel Bloom solves this by automatically:
- 🔍 Analyzing your Eloquent models and database schema
- 🗂 Generating migration files in the correct dependency order
- 🎲 Populating tables with realistic, context-aware fake data
- 🔗 Resolving foreign keys and relationships automatically
- 🖼 Visualizing your entire database schema interactively
🚀 Installation
composer require msme/laravel-bloom
🧩 How It Works
Bloom reads your app/Models directory and inspects each model's:
$fillable— to know which columns to generate$types— your explicit column type declarations (e.g.'price' => 'decimal')$casts— to infer types for boolean, json, hashed fields- Relationship methods — only methods declared directly on your model (not inherited from
Model,Authenticatable, traits, etc.)
This gives Bloom what it needs to generate migrations, seed data, and draw the schema graph — with zero extra configuration.
Column type resolution
Bloom resolves each column's type using a priority chain — $types wins, but everything else is inferred automatically:
1. public $types → explicit developer declaration (highest priority)
2. $casts → boolean, array → json, hashed → string
3. field name → anything ending in _id → foreignId
4. default → string (fallback)
This means $types is optional for most columns. Bloom already handles the common cases:
class Post extends Model { protected $fillable = ['user_id', 'title', 'slug', 'content', 'published', 'metadata']; protected $casts = [ 'published' => 'boolean', // ✅ Bloom infers → boolean column 'metadata' => 'array', // ✅ Bloom infers → json column ]; // $types not needed here — everything is covered by casts + naming conventions }
You only need $types for columns where the type cannot be inferred from the name or cast — most commonly text, decimal, float, integer, and timestamp:
class Product extends Model { protected $fillable = ['name', 'description', 'price', 'stock', 'launched_at']; public $types = [ 'description' => 'text', // would default to string without this 'price' => 'decimal', // would default to string without this 'stock' => 'integer', // would default to string without this 'launched_at' => 'timestamp', // would default to string without this ]; }
Supported types
| Type | Migration column | Notes |
|---|---|---|
string |
->string() |
Default fallback |
text |
->text() |
For long-form content |
integer |
->integer() |
Whole numbers |
float |
->float() |
Floating point |
decimal |
->decimal(10, 2) |
For prices and money |
boolean |
->boolean() |
Also inferred from $casts |
json |
->json() |
Also inferred from array cast |
timestamp |
->timestamp()->nullable() |
For date/time columns |
foreignId |
->foreignId()->constrained() |
Auto-detected from _id suffix |
Fields Bloom already understands without $types
| Convention | Auto-detected as |
|---|---|
Any field ending in _id |
foreignId |
$casts entry of boolean |
boolean |
$casts entry of array |
json |
$casts entry of hashed |
string |
$casts entry of integer |
integer |
| Anything else | string |
🗺 Commands
Generate Migrations
Inspects your models and generates migration files into database/migrations/bloom/.
php artisan bloom:migrations
Bloom automatically:
- Detects foreign key columns (any
_idfield) and generates->foreignId()->constrained()->cascadeOnDelete() - Builds a dependency graph from your models and topologically sorts migrations so
usersalways comes beforeposts,postsbeforecomments, etc. - Assigns incrementing timestamps (
000000,000001,000002...)
Then run them:
php artisan migrate --path=/database/migrations/bloom
Populate Database
Fills your tables with smart fake data based on column names and types.
# Populate all tables (respects dependency order automatically) php artisan bloom:populate # Populate a specific table php artisan bloom:populate users # Control the number of records php artisan bloom:populate posts --count=100 # Truncate before seeding php artisan bloom:populate comments --count=500 --truncate # Skip auto-seeding dependency tables php artisan bloom:populate posts --no-deps
Smart value generation
Bloom maps column names to realistic fake data before falling back to types.
Bloom auto-seeds dependency tables — if you populate comments and posts is empty, it seeds posts first (and users before that). Use --no-deps to skip this.
🖼 Schema Visualizer
Bloom ships with a built-in interactive schema visualizer accessible at:
/bloom/schema-visualizer
No setup required — just navigate to the route in your browser.
🤝 Contributing
Contributions are welcome!
- Fork the repository
- Create a feature branch
- Submit a pull request
Please follow Laravel coding conventions.
🧑💻 Author
Created by Mourad Bousserouel
If you find Laravel Bloom useful, consider giving the repository a ⭐
📜 License
Laravel Bloom is open-source software licensed under the MIT license.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-06