adereksisusanto / laravel-generator
Generate Laravel models, migrations, and seeders from existing database tables
Package info
github.com/adereksisusanto/laravel-generator
pkg:composer/adereksisusanto/laravel-generator
Fund package maintenance!
Requires
- php: ^8.3
- illuminate/console: ^13.0
- illuminate/filesystem: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^11.0
- phpstan/phpstan: ^1.4|^2.0
- phpunit/phpunit: ^11.5.3|^12.0.1|^13.0.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Generate Laravel models, migrations, and seeders directly from your existing database tables.
Supports MySQL, PostgreSQL, SQLite, and SQL Server. Compatible with PHP 8.3+ and Laravel 13.
Installation
composer require adereksisusanto/laravel-generator
Publish config (optional):
php artisan vendor:publish --provider="Adereksisusanto\Laravel\Generator\ServiceProvider" --tag=config
Commands
# Generate all (models + migrations + seeders) php artisan generate # Individual generators php artisan generate:model php artisan generate:migration php artisan generate:seeder
Options
# Specific tables php artisan generate:model --tables=users,posts # Custom namespace (model only) php artisan generate:model --namespace="App\Models" # Record limit (seeder only, 0 = unlimited) php artisan generate:seeder --limit=50 # Overwrite existing files php artisan generate:model --force # Custom connection php artisan generate:model --connection=mysql # Also generate migration and/or seeder with model php artisan generate:model --tables=users -m php artisan generate:model --tables=users -s php artisan generate:model --tables=users -ms
Combined command flags (generate)
| Flag | Description |
|---|---|
--model-only |
Generate only models |
--migration-only |
Generate only migrations |
--seeder-only |
Generate only seeders |
--seeder-limit |
Max seed records (0 = unlimited) |
What Gets Generated
Models
Eloquent model with $fillable, $casts, $hidden, relationships (belongsTo/hasMany), HasFactory trait, and SoftDeletes trait when deleted_at column exists.
Migrations
Schema::create() with proper column types, nullable, unsigned, defaults, and indexes.
Seeders
Model::insert([...]) populated with actual data from your database table.
Configuration
// config/generator.php 'tables' => [ 'includes' => [], 'excludes' => ['migrations', 'failed_jobs'], ], 'paths' => [ 'model' => app_path('Models'), 'migration' => database_path('migrations'), 'seeder' => database_path('seeders'), ], 'model' => [ 'timestamps' => true, 'soft_deletes' => false, 'relationships' => true, ], 'seeder' => [ 'limit' => 100, ],
Contributing
See CONTRIBUTING for contribution guidelines.
Changelog
See CHANGELOG for recent changes.
License
The MIT License (MIT). See LICENSE for more information.