PHPackages                             adly-nady/php-my-migration - 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. [Database &amp; ORM](/categories/database)
4. /
5. adly-nady/php-my-migration

ActiveLaravel-package[Database &amp; ORM](/categories/database)

adly-nady/php-my-migration
==========================

It converts all existing tables in MySQL that do not have migration files to migration files. If they exist, it compares the columns and their data types with the existing ones and syncs the existing ones to MySQL.

2.0.0(1y ago)49MITPHPPHP ^8.1|^8.2

Since Mar 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/adly-nady/php-my-migration)[ Packagist](https://packagist.org/packages/adly-nady/php-my-migration)[ RSS](/packages/adly-nady-php-my-migration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

🔄 PhpMyMigration
================

[](#-phpmymigration)

[![PHP Version](https://camo.githubusercontent.com/fb7c72456e13f7d5ecf8486e29d02a2e6775aaf4d18622a63529976b0ed0740e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d707572706c652e737667)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/06555b6198f0c2966c6333fb067e972ee274778091deda239034c7e9c774a28e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e7825323025374325323031302e7825323025374325323031312e782d7265642e737667)](https://laravel.com)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.md)

A powerful Laravel package that automatically generates migration files and Eloquent models from your existing database tables. Perfect for legacy projects or when you need to version control your database structure.

[Installation](#installation) • [Usage](#usage) • [Examples](#examples) • [Features](#features)

🌟 Features
----------

[](#-features)

- ✨ **Smart Migration Generation**

    - Automatically detects column types and properties
    - Handles primary keys (single and composite)
    - Supports foreign key relationships
    - Manages indexes and unique constraints
    - Includes timestamps and soft deletes
- 🎯 **Eloquent Model Generation**

    - Creates models with proper relationships
    - Adds comprehensive PHPDoc comments
    - Implements type casting
    - Supports soft deletes
    - Manages fillable fields
- 🚀 **Performance &amp; Flexibility**

    - Batch processing for large databases
    - Custom output paths
    - Force overwrite option
    - Multiple database connection support

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 9.x, 10.x, or 11.x
- MySQL database

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require adly-nady/php-my-migration
```

The package will automatically register its service provider.

💡 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

Generate migration files for all tables:

```
php artisan phpmymigration:generate
```

### Generate Migrations and Models

[](#generate-migrations-and-models)

Generate both migrations and Eloquent models:

```
php artisan phpmymigration:generate --with-models
```

### Generate Only Migrations

[](#generate-only-migrations)

Generate only migration files (default behavior):

```
php artisan phpmymigration:generate --only-migrations
```

### Specify Database Connection

[](#specify-database-connection)

Use a specific database connection:

```
php artisan phpmymigration:generate --connection=mysql
```

### Force Overwrite

[](#force-overwrite)

Overwrite existing migration/model files:

```
php artisan phpmymigration:generate --force
```

### Custom Output Path

[](#custom-output-path)

Specify custom paths for migrations and models:

```
php artisan phpmymigration:generate --path=/custom/path
```

This will create:

- `/custom/path/migrations/` for migration files
- `/custom/path/Models/` for model files

📝 Examples
----------

[](#-examples)

### Generated Migration Example

[](#generated-migration-example)

For a `users` table with relationships:

```
