PHPackages                             ridtichai/laravel-existing-db-migration-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ridtichai/laravel-existing-db-migration-generator

ActiveLibrary

ridtichai/laravel-existing-db-migration-generator
=================================================

Generate Laravel migration and seeder files from an existing database schema.

v0.2.7(1mo ago)012—0%MITPHPPHP ^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3

Since Mar 18Pushed 1mo agoCompare

[ Source](https://github.com/ridtichai/laravel-existing-db-migration-generator)[ Packagist](https://packagist.org/packages/ridtichai/laravel-existing-db-migration-generator)[ RSS](/packages/ridtichai-laravel-existing-db-migration-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (10)Used By (0)

Laravel Existing DB Migration Generator
=======================================

[](#laravel-existing-db-migration-generator)

Generate Laravel **migration** and **seeder** files from an existing database schema.

---

🚀 Features
----------

[](#-features)

### 🧱 Migration Generator

[](#-migration-generator)

- Generate migration files from existing database tables
- Convert schema into Laravel-friendly syntax:

    - `$table->id()`
    - `$table->timestamps()`
    - `$table->foreignId()->constrained()`
- Support Laravel 8.75+
- Support PHP 7.4 and PHP 8+
- Works with MySQL, MariaDB, PostgreSQL, SQLite

---

### 🌱 Seeder Generator

[](#-seeder-generator)

- Export table data into Laravel seeders
- Support:

    - `--all` generate all tables
    - auto sort by foreign key dependency
    - auto register into `DatabaseSeeder`
    - auto create `DatabaseSeeder` if not exists
    - `--truncate` or `delete()` option
    - chunk insert for large data
    - multi-file seeder for big tables

---

### 🧩 CRUD Generator

[](#-crud-generator)

- Generate CRUD controller and Blade views from existing database tables
- Use **Eloquent Model** instead of Query Builder
- Use **Bootstrap 5.2.3** as the default UI base
- Read column comments in format `label#input_type`
- Support configurable Blade parent path
- Support configurable default Bootstrap form columns

---

📦 Installation
--------------

[](#-installation)

```
composer require ridtichai/laravel-existing-db-migration-generator
```

---

⚙️ Migration Usage
------------------

[](#️-migration-usage)

```
php artisan existing-db:generate-migrations
```

### Options

[](#options)

OptionDescription`--connection=`Database connection`--path=`Output path`--table=`Specific tables`--ignore=`Ignore tables---

🌱 Seeder Usage
--------------

[](#-seeder-usage)

### Generate specific table

[](#generate-specific-table)

```
php artisan existing-db:generate-seeders --table=config_system
```

---

### Generate multiple tables

[](#generate-multiple-tables)

```
php artisan existing-db:generate-seeders --table=users --table=roles
```

---

### Generate all tables (🔥 recommended)

[](#generate-all-tables--recommended)

```
php artisan existing-db:generate-seeders --all
```

---

### With truncate

[](#with-truncate)

```
php artisan existing-db:generate-seeders --all --truncate
```

---

### Force overwrite

[](#force-overwrite)

```
php artisan existing-db:generate-seeders --all --force
```

---

### Disable auto register

[](#disable-auto-register)

```
php artisan existing-db:generate-seeders --all --no-register
```

---

🧠 Smart Features
----------------

[](#-smart-features)

### 🔗 Auto Sort by Foreign Key

[](#-auto-sort-by-foreign-key)

Tables will be generated in correct order:

```
payment_status → payments → logs

```

---

### 📦 Multi-file Seeder

[](#-multi-file-seeder)

Large tables will be split automatically:

```
UsersTableSeederPart1
UsersTableSeederPart2
UsersTableSeederPart3

```

---

### 🧩 Auto Register Seeder

[](#-auto-register-seeder)

Generated seeders will be automatically added to:

```
DatabaseSeeder.php
```

---

### 🛠 Auto Create DatabaseSeeder

[](#-auto-create-databaseseeder)

If not exists:

```
database/seeders/DatabaseSeeder.php
```

Will be generated automatically.

---

🧩 CRUD Usage

### Generate CRUD from an existing table:

[](#generate-crud-from-an-existing-table)

```
php artisan existing-db:generate-crud --table=users
```

### Force overwrite existing files:

[](#force-overwrite-existing-files)

```
php artisan existing-db:generate-crud --table=users --force
```

### Specify database connection:

[](#specify-database-connection)

```
php artisan existing-db:generate-crud --connection=mysql --table=users
```

📁 CRUD Generated Files

### For:

[](#for)

```
php artisan existing-db:generate-crud --table=users
```

### the package generates files like:

[](#the-package-generates-files-like)

```
app/Http/Controllers/UserController.php
resources/views/users/index.blade.php
resources/views/users/create.blade.php
resources/views/users/edit.blade.php
resources/views/users/_form.blade.php
```

If view\_parent\_path is configured, the views will be generated inside that path.

### Example config:

[](#example-config)

```
'view_parent_path' => 'pages/admin',
```

### Generated views:

[](#generated-views)

```
resources/views/pages/admin/users/index.blade.php
resources/views/pages/admin/users/create.blade.php
resources/views/pages/admin/users/edit.blade.php
resources/views/pages/admin/users/_form.blade.php
```

✅ Supported Input Types

### Supported input types in column comments:

[](#supported-input-types-in-column-comments)

- text
- textarea
- number
- email
- password
- date
- datetime
- datetime-local
- time
- select
- radio
- checkbox
- file
- hidden

### Example:

[](#example)

```
ชื่อ#text
รายละเอียด#textarea
จำนวน#number
อีเมล#email
รหัสผ่าน#password
สถานะ#select
```

---

🔧 Configuration
---------------

[](#-configuration)

Publish config:

```
php artisan vendor:publish --tag=existing-db-migration-generator-config
```

Example:

```
return [
    'default_output_path' => 'database/migrations',
    'default_seeder_output_path' => 'database/seeders',

    'exclude_tables' => [
        'migrations',
        'password_resets',
        'failed_jobs',
        'personal_access_tokens',
    ],

    'crud' => [
        'layout' => 'layouts.index',
        'view_parent_path' => 'pages/admin',
        'form_columns' => 2,
        'model_namespace' => 'App\\Models',
        'controller_namespace' => 'App\\Http\\Controllers',
    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Style Macros
    |--------------------------------------------------------------------------
    |
    | When enabled, the generator will try to output Laravel-style shortcuts:
    | - $table->id()
    | - $table->timestamps()
    | - $table->foreignId(...)->constrained(...)
    |
    | When disabled, the generator will stay closer to the original schema.
    |
    */
    'use_laravel_style_macros' => true,
    'omit_default_string_length' => true,

    'auto_register_seeder' => true,

    'multi_file_seed_threshold' => 1000,
];
```

---

📁 Example Output
----------------

[](#-example-output)

### Seeder

[](#seeder)

```
DB::table('config_system')->insert([
    [
        'id' => 1,
        'name' => 'Example',
        'created_at' => null,
    ],
]);
```

---

⚠️ Limitations
--------------

[](#️-limitations)

- Complex foreign keys (composite) not fully supported
- Some database-specific types may need manual adjustment
- `truncate()` may fail with strict FK constraints

---

🧪 Compatibility
---------------

[](#-compatibility)

LaravelPHP8.75+7.4 - 8.2+---

📌 Roadmap
---------

[](#-roadmap)

- Index support
- Unique &amp; composite key support
- Disable/enable foreign key checks option
- Data-only / schema-only mode
- Seeder rollback support

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome!

---

📄 License
---------

[](#-license)

MIT License

Changelog
---------

[](#changelog)

### v0.2.0

[](#v020)

- Add seeder generator
- Add --all option
- Auto sort by foreign key dependency
- Auto register DatabaseSeeder
- Multi-file seed support
- Truncate option

### v0.2.6

[](#v026)

- Added existing-db:generate-crud command
- Generate CRUD from existing database tables
- Generate Eloquent-based controller
- Generate Blade views:
- index.blade.php
- create.blade.php
- edit.blade.php
- \_form.blade.php
- Support column comment format label#input\_type
- Support foreign key select field generation
- Support configurable form\_columns
- Support configurable layout
- Support configurable model\_namespace
- Support configurable controller\_namespace

Changed

- CRUD generator uses Bootstrap 5.2.3 as the default UI base
- Generated controllers use Eloquent Model instead of Query Builder
- Generated views support configurable parent path

Notes

- Suitable for initial scaffolding after generating migrations and seeders
- Recommended to review routes, models, and relations before production use

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

9

Last Release

54d ago

PHP version history (2 changes)v0.1.0PHP ^7.4 || ^8.0

v0.2.2PHP ^7.4 || ^8.0 || ^8.1 || ^8.2 || ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cd4b311d2a517ce7f78377389ad4dd9a0e5c1c10b58e3daa34414bd63b1a616?d=identicon)[ridtichai](/maintainers/ridtichai)

---

Top Contributors

[![ridtichai](https://avatars.githubusercontent.com/u/12321771?v=4)](https://github.com/ridtichai "ridtichai (20 commits)")

### Embed Badge

![Health badge](/badges/ridtichai-laravel-existing-db-migration-generator/health.svg)

```
[![Health](https://phpackages.com/badges/ridtichai-laravel-existing-db-migration-generator/health.svg)](https://phpackages.com/packages/ridtichai-laravel-existing-db-migration-generator)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
