PHPackages                             aldeebhasan/migration-mapper - 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. aldeebhasan/migration-mapper

ActiveLibrary[Database &amp; ORM](/categories/database)

aldeebhasan/migration-mapper
============================

This package is designed to enable the developer to generate the migration files by just building his model

1.0.0(2y ago)24MITPHPPHP &gt;=8.1

Since Feb 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/aldeebhasan/migration-mapper)[ Packagist](https://packagist.org/packages/aldeebhasan/migration-mapper)[ RSS](/packages/aldeebhasan-migration-mapper/feed)WikiDiscussions main Synced today

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

Laravel Migration Mapper Package
================================

[](#laravel-migration-mapper-package)

Automatically generate you migration files from your models

Why
---

[](#why)

One of the most important and critical part of laravel application is the migration files. Each time you need to add s single column to your table, you need to go to the console, create your migration file, add your migration commands and finally run the migrations.

This package will hide this over head from you, you only need to define the blueprint of you model and we will handle everything automatically.

Installation
------------

[](#installation)

Install using composer:

```
composer require aldeebhasan/migration-mapper
```

After installation run the following code to publish the config:

```
php artisan vendor:publish --tag=migration-mapper-config
```

Basic Usage
-----------

[](#basic-usage)

Let's suppose that you have a model named as `Product` with three parameters `[id,name,description,category_id,visisble]` as Follow:

```
#[Table(
    name: 'x_models', // optional
    columns: [
        new Id(),
        new String_('name', length:255, default: "admin"),
        new Text('description', length:255, default: "admin"),
        new BigInteger('category_id', nullable: true, index: true, unsigned: true),
        new Enum('visible', ['off', 'on'], default: 'off', comment: 'status of the product'),
    ]
)]
class XModel extends Model
{
    protected $fillable = [
        'name', 'description', 'category_id'
    ];
}
```

Each time you want to generate the migration files, you simply need to call:

```
php artisan mapper:generate
```

The result of the above command will be:

```
database
    migrations
        2024_02_19_1708369156_create_x_models_table_m.php

```

***Note that the `name` parameter of table is optional. If it doesn't provided we will detect the table name from the model***

---

If you want to discard all previous changes and migratin and start again from scratch, you can use the following command:

```
php artisan mapper:regenerate
```

By calling it we will delete all the migration files, all our logs and start again from zero.

---

At any point of time, if you want to rollback the last generation process, you can use the following command:

```
php artisan mapper:rollback
```

### Supported Column Type

[](#supported-column-type)

- Boolean()
- Date()
- DateTme()
- Time()
- TinyInteger()
- SmallInteger()
- Integer()
- MediumInteger()
- BigInteger()
- Decimal()
- Double()
- Float\_()
- Enum()
- Id()
- String\_()
- TinyText()
- SmallText()
- MediumText()
- Text()
- LongText()

Each of these types has a specific parameters that represent the operation the can handle.

### Relations:

[](#relations)

This package can also handle the relation between models. The relation that we may interest in is `Many To One` and `Many To Many` relations, since they have direct effect on the model itself

lets consider that we have the following model:

```
#[Table(
    columns: [
        new Id(),
        new String_('name', length:255, default: "admin"),
        new BigInteger('category_id',unsigned: true,index: true),
    ]
)]
class Product extends Model
{
    protected $fillable = [
        'name','category_id'
    ];

    #[ManyToOne(related: Category::class)]
    public function category(): HasMany
    {
        return $this->belongsTo(Category::class, 'category_id')
    }

    #[ManyToMany(related: Product::class, table: 'product_related', foreignKey: 'source_id', localKey: 'id', targetForeignKey: 'target_id', targetLocalKey: 'id')]
    public function related_products(): BelongsToMany
    {
        return $this->belongsToMany(Product::class,'product_related', 'source_id', 'target_id');
    }

}
```

By calling `php artisan mapper:generate`, the package will generate two tables for you and we will get the followings:

```
database
    migrations
        2024_02_19_1708369156_create_products_table_m.php
        2024_02_19_1708369157_create_product_related_table_m.php

```

***Please Note the other kind of relation has no effect over the model, so there is no idea of handling them.***

License
-------

[](#license)

Laravel Migration Mapper package is licensed under [The MIT License (MIT)](LICENSE).

Security contact information
----------------------------

[](#security-contact-information)

To report a security vulnerability, contact directly to the developer contact email [Here](mailto:aldeeb.91@gmail.com).

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

864d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74e7b9d93b0f666f462ad0be43dde05991e9d141f9fe840009775808107d440e?d=identicon)[aldeebhasan](/maintainers/aldeebhasan)

---

Top Contributors

[![aldeebhasan](https://avatars.githubusercontent.com/u/62222392?v=4)](https://github.com/aldeebhasan "aldeebhasan (1 commits)")

---

Tags

database-model-mapperlaravellaravel-migratelaravel-packagemigrationsmodel-migratelaravelmigratelaravel migratemodel migratehandle modlemigration mapperdatabase model mapper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aldeebhasan-migration-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/aldeebhasan-migration-mapper/health.svg)](https://phpackages.com/packages/aldeebhasan-migration-mapper)
```

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8465.5M96](/packages/laravel-doctrine-orm)[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

1.0k2.4M29](/packages/tpetry-laravel-postgresql-enhanced)[jaybizzle/laravel-migrations-organiser

A Laravel package to help organise migration files.

113409.8k2](/packages/jaybizzle-laravel-migrations-organiser)[giacomomasseron/laravel-models-generator

Generate Laravel models from an existing database

557.5k](/packages/giacomomasseron-laravel-models-generator)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14385.8k4](/packages/flow-php-doctrine-dbal-bulk)

PHPackages © 2026

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