Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php My Migration Laravel Package

adly-nady/php-my-migration

Laravel package to generate migrations (and optional Eloquent models) from an existing MySQL database. Detects column types, keys, indexes, foreign keys, timestamps/soft deletes; supports batch processing, custom paths, overwrite, and connections.

View on GitHub
Deep Wiki
Context7

🔄 PhpMyMigration

PHP Version Laravel Version License

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.

InstallationUsageExamplesFeatures

🌟 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 & Flexibility

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

📋 Requirements

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

🚀 Installation

Install the package via Composer:

composer require adly-nady/php-my-migration

The package will automatically register its service provider.

💡 Usage

Basic Usage

Generate migration files for all tables:

php artisan phpmymigration:generate

Generate Migrations and Models

Generate both migrations and Eloquent models:

php artisan phpmymigration:generate --with-models

Generate Only Migrations

Generate only migration files (default behavior):

php artisan phpmymigration:generate --only-migrations

Specify Database Connection

Use a specific database connection:

php artisan phpmymigration:generate --connection=mysql

Force Overwrite

Overwrite existing migration/model files:

php artisan phpmymigration:generate --force

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

Generated Migration Example

For a users table with relationships:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    public function down()
    {
        Schema::dropIfExists('users');
    }
};

Generated Model Example

For the same users table:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * User Model
 *
 * @property int $id
 * @property string $name
 * @property string $email
 * @property \DateTime|null $email_verified_at
 * @property string $password
 * @property string|null $remember_token
 * @property \DateTime $created_at
 * @property \DateTime $updated_at
 * @property \DateTime|null $deleted_at
 */
class User extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    protected $casts = [
        'email_verified_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];
}

👨‍💻 About Me

Hi! I'm Adly Nady, a passionate Laravel developer. I love creating tools that make developers' lives easier. This package is one of my contributions to the Laravel ecosystem.

Connect With Me

LinkedIn Facebook GitHub

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE.md file for details.


Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager